Skip to content

Commit

Permalink
[SCSI] iscsi: fix session refcouting
Browse files Browse the repository at this point in the history
iscsi_tcp and iser cannot be rmmod from the kernel when sessions
are running because session removal is driven from userspace. For
those modules we get a module reference when a session is
created then drop it when the session is removed.

For qla4xxx, they can jsut remove the sessions from the pci remove
function like normal HW drivers, so this patch moves the module
reference from the transport class functions shared by all
drivers to the libiscsi functions only used be software iscsi
modules.

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 5c75b7f commit f53a88d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 7 additions & 1 deletion drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,13 +1287,18 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
if (scsi_add_host(shost, NULL))
goto add_host_fail;

if (!try_module_get(iscsit->owner))
goto cls_session_fail;

cls_session = iscsi_create_session(shost, iscsit, 0);
if (!cls_session)
goto cls_session_fail;
goto module_put;
*(unsigned long*)shost->hostdata = (unsigned long)cls_session;

return cls_session;

module_put:
module_put(iscsit->owner);
cls_session_fail:
scsi_remove_host(shost);
add_host_fail:
Expand Down Expand Up @@ -1325,6 +1330,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)

iscsi_destroy_session(cls_session);
scsi_host_put(shost);
module_put(cls_session->transport->owner);
}
EXPORT_SYMBOL_GPL(iscsi_session_teardown);

Expand Down
10 changes: 2 additions & 8 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,11 @@ static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid)
static void iscsi_session_release(struct device *dev)
{
struct iscsi_cls_session *session = iscsi_dev_to_session(dev);
struct iscsi_transport *transport = session->transport;
struct Scsi_Host *shost;

shost = iscsi_session_to_shost(session);
scsi_host_put(shost);
kfree(session);
module_put(transport->owner);
}

static int iscsi_is_session_dev(const struct device *dev)
Expand Down Expand Up @@ -305,13 +303,11 @@ iscsi_create_session(struct Scsi_Host *shost,
struct iscsi_cls_session *session;
int err;

if (!try_module_get(transport->owner))
return NULL;

session = kzalloc(sizeof(*session) + transport->sessiondata_size,
GFP_KERNEL);
if (!session)
goto module_put;
return NULL;

session->transport = transport;
session->recovery_tmo = 120;
INIT_WORK(&session->recovery_work, session_recovery_timedout, session);
Expand Down Expand Up @@ -349,8 +345,6 @@ iscsi_create_session(struct Scsi_Host *shost,

free_session:
kfree(session);
module_put:
module_put(transport->owner);
return NULL;
}

Expand Down

0 comments on commit f53a88d

Please sign in to comment.