@@ -44,6 +44,7 @@
#include <linux/types.h>
#include <linux/net.h>
#include <linux/printk.h>
+#include <linux/refcount.h>
Would be nice to split that to a separate patch as well.
btw general comment. please CC target-devel for isert patches
and linux-nvme for nvme(t)-rdma patches. Thanks.
#include <scsi/libiscsi.h>
#include <scsi/scsi_transport_iscsi.h>
#include <scsi/scsi_cmnd.h>
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index b7da1a6ea32c..560c328c32d8 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -42,8 +42,7 @@ static int isert_debug_level;
module_param_named(debug_level, isert_debug_level, int, 0644);
MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0 (default:0)");
-static DEFINE_MUTEX(device_list_mutex);
-static LIST_HEAD(device_list);
+static struct ib_client isert_rdma_ib_client;
static struct workqueue_struct *isert_comp_wq;
static struct workqueue_struct *isert_release_wq;
@@ -341,56 +340,51 @@ isert_free_device_ib_res(struct isert_device *device)
static void
isert_device_put(struct isert_device *device)
{
- mutex_lock(&device_list_mutex);
- device->refcount--;
- isert_info("device %p refcount %d\n", device, device->refcount);
- if (!device->refcount) {
+ isert_info("device %p refcount %d\n", device,
+ refcount_read(&device->refcount));
+ if (refcount_dec_and_test(&device->refcount)) {
isert_free_device_ib_res(device);
list_del(&device->dev_node);
kfree(device);
}
- mutex_unlock(&device_list_mutex);
}
static struct isert_device *
isert_device_get(struct rdma_cm_id *cma_id)
{
struct isert_device *device;
- int ret;
- mutex_lock(&device_list_mutex);
- list_for_each_entry(device, &device_list, dev_node) {
- if (device->ib_device->node_guid == cma_id->device->node_guid) {
- device->refcount++;
- isert_info("Found iser device %p refcount %d\n",
- device, device->refcount);
- mutex_unlock(&device_list_mutex);
- return device;
- }
- }
+ /* Paired with isert_ib_client_remove_one() */
+ rcu_read_lock();
Same comment as from last patch, other than that looks good!
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html