mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-29 18:00:18 +00:00
Fixed data races on manipulation of the srpt_devices list by eliminating
this list. Only the number of IB devices is relevant for the SRPT implementation. Introduced a new counter that tracks the number of IB devices. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1016 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -84,7 +84,7 @@ struct srpt_thread {
|
||||
|
||||
static u64 mellanox_ioc_guid;
|
||||
/* List of srpt_device structures. */
|
||||
static struct list_head srpt_devices;
|
||||
static atomic_t srpt_device_count;
|
||||
static int thread;
|
||||
static struct srpt_thread srpt_thread;
|
||||
static DECLARE_WAIT_QUEUE_HEAD(ioctx_list_waitQ);
|
||||
@@ -2345,17 +2345,15 @@ static void srpt_refresh_port_work(struct work_struct *work)
|
||||
*/
|
||||
static int srpt_detect(struct scst_tgt_template *tp)
|
||||
{
|
||||
struct srpt_device *sdev;
|
||||
int count = 0;
|
||||
int device_count;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
list_for_each_entry(sdev, &srpt_devices, list)
|
||||
++count;
|
||||
device_count = atomic_read(&srpt_device_count);
|
||||
|
||||
TRACE_EXIT();
|
||||
TRACE_EXIT_RES(device_count);
|
||||
|
||||
return count;
|
||||
return device_count;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2681,8 +2679,6 @@ static void srpt_add_one(struct ib_device *device)
|
||||
for (i = 0; i < SRPT_SRQ_SIZE; ++i)
|
||||
srpt_post_recv(sdev, sdev->ioctx_ring[i]);
|
||||
|
||||
list_add_tail(&sdev->list, &srpt_devices);
|
||||
|
||||
ib_set_client_data(device, &srpt_client, sdev);
|
||||
|
||||
sdev->scst_tgt = scst_register(&srpt_template, NULL);
|
||||
@@ -2714,6 +2710,8 @@ static void srpt_add_one(struct ib_device *device)
|
||||
}
|
||||
}
|
||||
|
||||
atomic_inc(&srpt_device_count);
|
||||
|
||||
TRACE_EXIT();
|
||||
|
||||
return;
|
||||
@@ -2722,7 +2720,6 @@ err_refresh_port:
|
||||
scst_unregister(sdev->scst_tgt);
|
||||
err_ring:
|
||||
ib_set_client_data(device, &srpt_client, NULL);
|
||||
list_del(&sdev->list);
|
||||
srpt_free_ioctx_ring(sdev);
|
||||
err_event:
|
||||
ib_unregister_event_handler(&sdev->event_handler);
|
||||
@@ -2799,7 +2796,6 @@ static void srpt_remove_one(struct ib_device *device)
|
||||
#endif
|
||||
|
||||
srpt_free_ioctx_ring(sdev);
|
||||
list_del(&sdev->list);
|
||||
kfree(sdev);
|
||||
|
||||
TRACE_EXIT();
|
||||
@@ -2859,8 +2855,6 @@ static int __init srpt_init_module(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
INIT_LIST_HEAD(&srpt_devices);
|
||||
|
||||
ret = class_register(&srpt_class);
|
||||
if (ret) {
|
||||
printk(KERN_ERR PFX "couldn't register class ib_srpt\n");
|
||||
|
||||
@@ -198,8 +198,6 @@ struct srpt_device {
|
||||
*/
|
||||
struct ib_device_attr dev_attr;
|
||||
struct srpt_ioctx *ioctx_ring[SRPT_SRQ_SIZE];
|
||||
/* List node for insertion in the srpt_devices list. */
|
||||
struct list_head list;
|
||||
/*
|
||||
* List node for insertion in the srpt_rdma_ch::list list.
|
||||
* This list is protected by srpt_device::spinlock.
|
||||
|
||||
Reference in New Issue
Block a user