[openib-general] [PATCH 4 of 4] RFC: revert module ref counting patches
Michael S. Tsirkin
mst at mellanox.co.il
Mon Apr 10 04:18:21 PDT 2006
Revert module ref counting patch for SA. I expect the same to
apply to for-2.6.17.
Index: linux-2.6.16/drivers/infiniband/core/sa_query.c
===================================================================
--- linux-2.6.16/drivers/infiniband/core/sa_query.c (revision 6310)
+++ linux-2.6.16/drivers/infiniband/core/sa_query.c (revision 6309)
@@ -73,7 +73,6 @@
struct ib_sa_query {
void (*callback)(struct ib_sa_query *, int, struct ib_sa_mad *);
void (*release)(struct ib_sa_query *);
- struct module *owner;
struct ib_sa_port *port;
struct ib_mad_send_buf *mad_buf;
struct ib_sa_sm_ah *sm_ah;
@@ -573,16 +572,15 @@
* error code. Otherwise it is a query ID that can be used to cancel
* the query.
*/
-int __ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
- struct ib_sa_path_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_path_rec *resp,
- void *context),
- void *context,
- struct module *owner,
- struct ib_sa_query **sa_query)
+int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
+ struct ib_sa_path_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_path_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
{
struct ib_sa_path_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
@@ -617,7 +615,6 @@
query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
query->sa_query.release = ib_sa_path_rec_release;
- query->sa_query.owner = owner;
query->sa_query.port = port;
mad->mad_hdr.method = IB_MGMT_METHOD_GET;
mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC);
@@ -641,7 +638,7 @@
kfree(query);
return ret;
}
-EXPORT_SYMBOL(__ib_sa_path_rec_get);
+EXPORT_SYMBOL(ib_sa_path_rec_get);
static void ib_sa_service_rec_callback(struct ib_sa_query *sa_query,
int status,
@@ -691,16 +688,15 @@
* error code. Otherwise it is a request ID that can be used to cancel
* the query.
*/
-int __ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
- struct ib_sa_service_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_service_rec *resp,
- void *context),
- void *context,
- struct module *owner,
- struct ib_sa_query **sa_query)
+int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
+ struct ib_sa_service_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_service_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
{
struct ib_sa_service_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
@@ -740,7 +736,6 @@
query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL;
query->sa_query.release = ib_sa_service_rec_release;
- query->sa_query.owner = owner;
query->sa_query.port = port;
mad->mad_hdr.method = method;
mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_SERVICE_REC);
@@ -765,7 +760,7 @@
kfree(query);
return ret;
}
-EXPORT_SYMBOL(__ib_sa_service_rec_query);
+EXPORT_SYMBOL(ib_sa_service_rec_query);
static void ib_sa_mcmember_rec_callback(struct ib_sa_query *sa_query,
int status,
@@ -789,17 +784,16 @@
kfree(container_of(sa_query, struct ib_sa_mcmember_query, sa_query));
}
-int __ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
- u8 method,
- struct ib_sa_mcmember_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_mcmember_rec *resp,
- void *context),
- void *context,
- struct module *owner,
- struct ib_sa_query **sa_query)
+int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
+ u8 method,
+ struct ib_sa_mcmember_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_mcmember_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
{
struct ib_sa_mcmember_query *query;
struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
@@ -834,7 +828,6 @@
query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
query->sa_query.release = ib_sa_mcmember_rec_release;
- query->sa_query.owner = owner;
query->sa_query.port = port;
mad->mad_hdr.method = method;
mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC);
@@ -859,16 +852,8 @@
kfree(query);
return ret;
}
-EXPORT_SYMBOL(__ib_sa_mcmember_rec_query);
+EXPORT_SYMBOL(ib_sa_mcmember_rec_query);
-static void call_sa_callback(struct ib_sa_query *query, int status,
- struct ib_sa_mad *mad)
-{
- BUG_ON(!try_module_get(query->owner));
- query->callback(query, status, mad);
- module_put(query->owner);
-}
-
static void send_handler(struct ib_mad_agent *agent,
struct ib_mad_send_wc *mad_send_wc)
{
@@ -881,13 +866,13 @@
/* No callback -- already got recv */
break;
case IB_WC_RESP_TIMEOUT_ERR:
- call_sa_callback(query, -ETIMEDOUT, NULL);
+ query->callback(query, -ETIMEDOUT, NULL);
break;
case IB_WC_WR_FLUSH_ERR:
- call_sa_callback(query, -EINTR, NULL);
+ query->callback(query, -EINTR, NULL);
break;
default:
- call_sa_callback(query, -EIO, NULL);
+ query->callback(query, -EIO, NULL);
break;
}
@@ -911,12 +896,12 @@
if (query->callback) {
if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
- call_sa_callback(query,
- mad_recv_wc->recv_buf.mad->mad_hdr.status ?
- -EINVAL : 0,
- (struct ib_sa_mad *) mad_recv_wc->recv_buf.mad);
+ query->callback(query,
+ mad_recv_wc->recv_buf.mad->mad_hdr.status ?
+ -EINVAL : 0,
+ (struct ib_sa_mad *) mad_recv_wc->recv_buf.mad);
else
- call_sa_callback(query, -EIO, NULL);
+ query->callback(query, -EIO, NULL);
}
ib_free_recv_mad(mad_recv_wc);
Index: linux-2.6.16/drivers/infiniband/include/rdma/ib_sa.h
===================================================================
--- linux-2.6.16/drivers/infiniband/include/rdma/ib_sa.h (revision 6310)
+++ linux-2.6.16/drivers/infiniband/include/rdma/ib_sa.h (revision 6309)
@@ -254,82 +254,39 @@
void ib_sa_cancel_query(int id, struct ib_sa_query *query);
-int __ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
- struct ib_sa_path_rec *rec,
+int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
+ struct ib_sa_path_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_path_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **query);
+
+int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
+ u8 method,
+ struct ib_sa_mcmember_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_mcmember_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **query);
+
+int ib_sa_service_rec_query(struct ib_device *device, u8 port_num,
+ u8 method,
+ struct ib_sa_service_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
- struct ib_sa_path_rec *resp,
+ struct ib_sa_service_rec *resp,
void *context),
void *context,
- struct module *owner,
- struct ib_sa_query **query);
+ struct ib_sa_query **sa_query);
-int __ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
- u8 method,
- struct ib_sa_mcmember_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_mcmember_rec *resp,
- void *context),
- void *context,
- struct module *owner,
- struct ib_sa_query **query);
-
-int __ib_sa_service_rec_query(struct ib_device *device, u8 port_num,
- u8 method,
- struct ib_sa_service_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_service_rec *resp,
- void *context),
- void *context,
- struct module *owner,
- struct ib_sa_query **sa_query);
-
/**
- * ib_sa_path_rec_get - Start a Path get query
- * @device:device to send query on
- * @port_num: port number to send query on
- * @rec:Path Record to send in query
- * @comp_mask:component mask to send in query
- * @timeout_ms:time to wait for response
- * @gfp_mask:GFP mask to use for internal allocations
- * @callback:function called when query completes, times out or is
- * canceled
- * @context:opaque user context passed to callback
- * @sa_query:query context, used to cancel query
- *
- * Send a Path Record Get query to the SA to look up a path. The
- * callback function will be called when the query completes (or
- * fails); status is 0 for a successful response, -EINTR if the query
- * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
- * occurred sending the query. The resp parameter of the callback is
- * only valid if status is 0.
- *
- * If the return value of ib_sa_path_rec_get() is negative, it is an
- * error code. Otherwise it is a query ID that can be used to cancel
- * the query.
- */
-static inline int
-ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
- struct ib_sa_path_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_path_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- return __ib_sa_path_rec_get(device, port_num, rec, comp_mask,
- timeout_ms, gfp_mask, callback,
- context, THIS_MODULE, sa_query);
-}
-
-/**
* ib_sa_mcmember_rec_set - Start an MCMember set query
* @device:device to send query on
* @port_num: port number to send query on
@@ -364,11 +321,11 @@
void *context,
struct ib_sa_query **query)
{
- return __ib_sa_mcmember_rec_query(device, port_num,
- IB_MGMT_METHOD_SET,
- rec, comp_mask,
- timeout_ms, gfp_mask, callback,
- context, THIS_MODULE, query);
+ return ib_sa_mcmember_rec_query(device, port_num,
+ IB_MGMT_METHOD_SET,
+ rec, comp_mask,
+ timeout_ms, gfp_mask, callback,
+ context, query);
}
/**
@@ -406,57 +363,14 @@
void *context,
struct ib_sa_query **query)
{
- return __ib_sa_mcmember_rec_query(device, port_num,
- IB_SA_METHOD_DELETE,
- rec, comp_mask,
- timeout_ms, gfp_mask, callback,
- context, THIS_MODULE, query);
+ return ib_sa_mcmember_rec_query(device, port_num,
+ IB_SA_METHOD_DELETE,
+ rec, comp_mask,
+ timeout_ms, gfp_mask, callback,
+ context, query);
}
/**
- * ib_sa_service_rec_query - Start Service Record operation
- * @device:device to send request on
- * @port_num: port number to send request on
- * @method:SA method - should be get, set, or delete
- * @rec:Service Record to send in request
- * @comp_mask:component mask to send in request
- * @timeout_ms:time to wait for response
- * @gfp_mask:GFP mask to use for internal allocations
- * @callback:function called when request completes, times out or is
- * canceled
- * @context:opaque user context passed to callback
- * @sa_query:request context, used to cancel request
- *
- * Send a Service Record set/get/delete to the SA to register,
- * unregister or query a service record.
- * The callback function will be called when the request completes (or
- * fails); status is 0 for a successful response, -EINTR if the query
- * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
- * occurred sending the query. The resp parameter of the callback is
- * only valid if status is 0.
- *
- * If the return value of ib_sa_service_rec_query() is negative, it is an
- * error code. Otherwise it is a request ID that can be used to cancel
- * the query.
- */
-static inline int
-ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
- struct ib_sa_service_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_service_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- return __ib_sa_service_rec_query(device, port_num, method, rec,
- comp_mask, timeout_ms, gfp_mask,
- callback, context, THIS_MODULE,
- sa_query);
-}
-
-/**
* ib_sa_pack_attr - Copy an SA attribute from a host defined structure to
* a network packed structure.
* dst: Destination buffer.
--
MST
More information about the general
mailing list