]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] iscsi transport: use atomic for session_nr allocations
authorMike Christie <michaelc@cs.wisc.edu>
Wed, 28 Feb 2007 23:32:18 +0000 (17:32 -0600)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sun, 11 Mar 2007 16:27:28 +0000 (11:27 -0500)
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>
drivers/scsi/scsi_transport_iscsi.c

index ce0d14af33c86a2e6c51abfa8a6ebc8dd50417ba..ff05c84479ca7058f6abd4baac3b3c5aa7a83090 100644 (file)
@@ -49,7 +49,7 @@ struct iscsi_internal {
        struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
 };
 
-static int iscsi_session_nr;   /* sysfs session id for next new session */
+static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
 
 /*
  * 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)
        int err;
 
        ihost = shost->shost_data;
-       session->sid = iscsi_session_nr++;
+       session->sid = atomic_add_return(1, &iscsi_session_nr);
        session->target_id = target_id;
 
        snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
@@ -1419,6 +1419,8 @@ static __init int iscsi_transport_init(void)
        printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
                ISCSI_TRANSPORT_VERSION);
 
+       atomic_set(&iscsi_session_nr, 0);
+
        err = class_register(&iscsi_transport_class);
        if (err)
                return err;