aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2007-02-28 18:32:18 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-03-11 12:27:28 -0400
commit41be14442213b6dbeea3cba2ed18a2923666278c (patch)
treea8796ed6c02049542a85099550e1c373d6ee41ca /drivers/scsi
parentbf32ed33e97ac7905fa5a2bf49a634c2eaf62457 (diff)
[SCSI] iscsi transport: use atomic for session_nr allocations
qla4xxx and iscsi_tcp or iser could be creating sessions at the same time, so make session_nr id allocation atomic. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index ce0d14af33c8..ff05c84479ca 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -49,7 +49,7 @@ struct iscsi_internal {
49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 49 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
50}; 50};
51 51
52static int iscsi_session_nr; /* sysfs session id for next new session */ 52static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
53 53
54/* 54/*
55 * list of registered transports and lock that must 55 * list of registered transports and lock that must
@@ -300,7 +300,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
300 int err; 300 int err;
301 301
302 ihost = shost->shost_data; 302 ihost = shost->shost_data;
303 session->sid = iscsi_session_nr++; 303 session->sid = atomic_add_return(1, &iscsi_session_nr);
304 session->target_id = target_id; 304 session->target_id = target_id;
305 305
306 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", 306 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
@@ -1419,6 +1419,8 @@ static __init int iscsi_transport_init(void)
1419 printk(KERN_INFO "Loading iSCSI transport class v%s.\n", 1419 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
1420 ISCSI_TRANSPORT_VERSION); 1420 ISCSI_TRANSPORT_VERSION);
1421 1421
1422 atomic_set(&iscsi_session_nr, 0);
1423
1422 err = class_register(&iscsi_transport_class); 1424 err = class_register(&iscsi_transport_class);
1423 if (err) 1425 if (err)
1424 return err; 1426 return err;