Skip to content

Commit

Permalink
[SCSI] iscsi transport: use atomic for session_nr allocations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Christie authored and James Bottomley committed Mar 11, 2007
1 parent bf32ed3 commit 41be144
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 41be144

Please sign in to comment.