Skip to content

Commit

Permalink
[SCSI] iscsi: pass target nr to session creation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Christie authored and James Bottomley committed Jun 29, 2006
1 parent 8434aa8 commit 6a8a0d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
if (!try_module_get(iscsit->owner))
goto cls_session_fail;

cls_session = iscsi_create_session(shost, iscsit);
cls_session = iscsi_create_session(shost, iscsit, 0);
if (!cls_session)
goto module_put;
*(unsigned long*)shost->hostdata = (unsigned long)cls_session;
Expand Down
14 changes: 7 additions & 7 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ iscsi_alloc_session(struct Scsi_Host *shost,
INIT_LIST_HEAD(&session->host_list);
INIT_LIST_HEAD(&session->sess_list);

/* this is released in the dev's release function */
scsi_host_get(shost);
session->dev.parent = &shost->shost_gendev;
session->dev.release = iscsi_session_release;
device_initialize(&session->dev);
Expand All @@ -313,18 +315,15 @@ iscsi_alloc_session(struct Scsi_Host *shost,
}
EXPORT_SYMBOL_GPL(iscsi_alloc_session);

int iscsi_add_session(struct iscsi_cls_session *session)
int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
{
struct Scsi_Host *shost = iscsi_session_to_shost(session);
struct iscsi_host *ihost;
int err;

/* this is released in the dev's release function */
scsi_host_get(shost);
ihost = shost->shost_data;

session->sid = iscsi_session_nr++;
session->target_id = ihost->next_target_id++;
session->target_id = target_id;

snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
session->sid);
Expand Down Expand Up @@ -356,15 +355,16 @@ EXPORT_SYMBOL_GPL(iscsi_add_session);
**/
struct iscsi_cls_session *
iscsi_create_session(struct Scsi_Host *shost,
struct iscsi_transport *transport)
struct iscsi_transport *transport,
unsigned int target_id)
{
struct iscsi_cls_session *session;

session = iscsi_alloc_session(shost, transport);
if (!session)
return NULL;

if (iscsi_add_session(session)) {
if (iscsi_add_session(session, target_id)) {
iscsi_free_session(session);
return NULL;
}
Expand Down
7 changes: 4 additions & 3 deletions include/scsi/scsi_transport_iscsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ struct iscsi_cls_session {
iscsi_dev_to_session(_stgt->dev.parent)

struct iscsi_host {
int next_target_id;
struct list_head sessions;
struct mutex mutex;
};
Expand All @@ -213,9 +212,11 @@ struct iscsi_host {
*/
extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost,
struct iscsi_transport *transport);
extern int iscsi_add_session(struct iscsi_cls_session *session);
extern int iscsi_add_session(struct iscsi_cls_session *session,
unsigned int target_id);
extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost,
struct iscsi_transport *t);
struct iscsi_transport *t,
unsigned int target_id);
extern void iscsi_remove_session(struct iscsi_cls_session *session);
extern void iscsi_free_session(struct iscsi_cls_session *session);
extern int iscsi_destroy_session(struct iscsi_cls_session *session);
Expand Down

0 comments on commit 6a8a0d3

Please sign in to comment.