diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2006-06-28 13:00:31 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-06-29 11:09:06 -0400 |
commit | 6a8a0d3621745279a131d95f0204dc9ddac60d55 (patch) | |
tree | e3e856d0a8b3f0697a1e59492dd840dbd3babb8a | |
parent | 8434aa8b6fe5af27a33b8aa830c24e3680356c83 (diff) |
[SCSI] iscsi: pass target nr to session creation
So the drivers do not use the channel numbers, but some do
use the target numbers. We were just adding some goofy
variable that just increases for the target nr. This is useless
for software iscsi because it is always zero. And for qla4xxx
the target nr is actually the index of the target/session
in its FW or FLASH tables. We needed to expose this to userspace
so apps could access those numbers so this patch just adds the
target nr to the iscsi session creation functions. This way
when qla4xxx's Hw thinks a session is at target nr 4
in its hw, it is exposed as that number in sysfs.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/libiscsi.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 14 | ||||
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 7 |
3 files changed, 12 insertions, 11 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 499e79f0cac5..7e6e031cc41b 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -1290,7 +1290,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, | |||
1290 | if (!try_module_get(iscsit->owner)) | 1290 | if (!try_module_get(iscsit->owner)) |
1291 | goto cls_session_fail; | 1291 | goto cls_session_fail; |
1292 | 1292 | ||
1293 | cls_session = iscsi_create_session(shost, iscsit); | 1293 | cls_session = iscsi_create_session(shost, iscsit, 0); |
1294 | if (!cls_session) | 1294 | if (!cls_session) |
1295 | goto module_put; | 1295 | goto module_put; |
1296 | *(unsigned long*)shost->hostdata = (unsigned long)cls_session; | 1296 | *(unsigned long*)shost->hostdata = (unsigned long)cls_session; |
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index f39da0cf5f18..7963c0538de5 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -304,6 +304,8 @@ iscsi_alloc_session(struct Scsi_Host *shost, | |||
304 | INIT_LIST_HEAD(&session->host_list); | 304 | INIT_LIST_HEAD(&session->host_list); |
305 | INIT_LIST_HEAD(&session->sess_list); | 305 | INIT_LIST_HEAD(&session->sess_list); |
306 | 306 | ||
307 | /* this is released in the dev's release function */ | ||
308 | scsi_host_get(shost); | ||
307 | session->dev.parent = &shost->shost_gendev; | 309 | session->dev.parent = &shost->shost_gendev; |
308 | session->dev.release = iscsi_session_release; | 310 | session->dev.release = iscsi_session_release; |
309 | device_initialize(&session->dev); | 311 | device_initialize(&session->dev); |
@@ -313,18 +315,15 @@ iscsi_alloc_session(struct Scsi_Host *shost, | |||
313 | } | 315 | } |
314 | EXPORT_SYMBOL_GPL(iscsi_alloc_session); | 316 | EXPORT_SYMBOL_GPL(iscsi_alloc_session); |
315 | 317 | ||
316 | int iscsi_add_session(struct iscsi_cls_session *session) | 318 | int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id) |
317 | { | 319 | { |
318 | struct Scsi_Host *shost = iscsi_session_to_shost(session); | 320 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
319 | struct iscsi_host *ihost; | 321 | struct iscsi_host *ihost; |
320 | int err; | 322 | int err; |
321 | 323 | ||
322 | /* this is released in the dev's release function */ | ||
323 | scsi_host_get(shost); | ||
324 | ihost = shost->shost_data; | 324 | ihost = shost->shost_data; |
325 | |||
326 | session->sid = iscsi_session_nr++; | 325 | session->sid = iscsi_session_nr++; |
327 | session->target_id = ihost->next_target_id++; | 326 | session->target_id = target_id; |
328 | 327 | ||
329 | snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", | 328 | snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", |
330 | session->sid); | 329 | session->sid); |
@@ -356,7 +355,8 @@ EXPORT_SYMBOL_GPL(iscsi_add_session); | |||
356 | **/ | 355 | **/ |
357 | struct iscsi_cls_session * | 356 | struct iscsi_cls_session * |
358 | iscsi_create_session(struct Scsi_Host *shost, | 357 | iscsi_create_session(struct Scsi_Host *shost, |
359 | struct iscsi_transport *transport) | 358 | struct iscsi_transport *transport, |
359 | unsigned int target_id) | ||
360 | { | 360 | { |
361 | struct iscsi_cls_session *session; | 361 | struct iscsi_cls_session *session; |
362 | 362 | ||
@@ -364,7 +364,7 @@ iscsi_create_session(struct Scsi_Host *shost, | |||
364 | if (!session) | 364 | if (!session) |
365 | return NULL; | 365 | return NULL; |
366 | 366 | ||
367 | if (iscsi_add_session(session)) { | 367 | if (iscsi_add_session(session, target_id)) { |
368 | iscsi_free_session(session); | 368 | iscsi_free_session(session); |
369 | return NULL; | 369 | return NULL; |
370 | } | 370 | } |
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 53493d591355..f7b0db5f2f5b 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -203,7 +203,6 @@ struct iscsi_cls_session { | |||
203 | iscsi_dev_to_session(_stgt->dev.parent) | 203 | iscsi_dev_to_session(_stgt->dev.parent) |
204 | 204 | ||
205 | struct iscsi_host { | 205 | struct iscsi_host { |
206 | int next_target_id; | ||
207 | struct list_head sessions; | 206 | struct list_head sessions; |
208 | struct mutex mutex; | 207 | struct mutex mutex; |
209 | }; | 208 | }; |
@@ -213,9 +212,11 @@ struct iscsi_host { | |||
213 | */ | 212 | */ |
214 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, | 213 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, |
215 | struct iscsi_transport *transport); | 214 | struct iscsi_transport *transport); |
216 | extern int iscsi_add_session(struct iscsi_cls_session *session); | 215 | extern int iscsi_add_session(struct iscsi_cls_session *session, |
216 | unsigned int target_id); | ||
217 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, | 217 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, |
218 | struct iscsi_transport *t); | 218 | struct iscsi_transport *t, |
219 | unsigned int target_id); | ||
219 | extern void iscsi_remove_session(struct iscsi_cls_session *session); | 220 | extern void iscsi_remove_session(struct iscsi_cls_session *session); |
220 | extern void iscsi_free_session(struct iscsi_cls_session *session); | 221 | extern void iscsi_free_session(struct iscsi_cls_session *session); |
221 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); | 222 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); |