aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2006-06-28 13:00:27 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-06-29 11:08:10 -0400
commitf53a88da18e3c04c3ade07bc5eff520ee4259c3e (patch)
treea3b89b4d0e621d5dbf051fd7b2191de7f053d312 /drivers/scsi/libiscsi.c
parent5c75b7fcf0c0e3921391fd93f5fa58ec9a6c428f (diff)
[SCSI] iscsi: fix session refcouting
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>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 7c76a989b218..7e6e031cc41b 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1287,13 +1287,18 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1287 if (scsi_add_host(shost, NULL)) 1287 if (scsi_add_host(shost, NULL))
1288 goto add_host_fail; 1288 goto add_host_fail;
1289 1289
1290 if (!try_module_get(iscsit->owner))
1291 goto cls_session_fail;
1292
1290 cls_session = iscsi_create_session(shost, iscsit, 0); 1293 cls_session = iscsi_create_session(shost, iscsit, 0);
1291 if (!cls_session) 1294 if (!cls_session)
1292 goto cls_session_fail; 1295 goto module_put;
1293 *(unsigned long*)shost->hostdata = (unsigned long)cls_session; 1296 *(unsigned long*)shost->hostdata = (unsigned long)cls_session;
1294 1297
1295 return cls_session; 1298 return cls_session;
1296 1299
1300module_put:
1301 module_put(iscsit->owner);
1297cls_session_fail: 1302cls_session_fail:
1298 scsi_remove_host(shost); 1303 scsi_remove_host(shost);
1299add_host_fail: 1304add_host_fail:
@@ -1325,6 +1330,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
1325 1330
1326 iscsi_destroy_session(cls_session); 1331 iscsi_destroy_session(cls_session);
1327 scsi_host_put(shost); 1332 scsi_host_put(shost);
1333 module_put(cls_session->transport->owner);
1328} 1334}
1329EXPORT_SYMBOL_GPL(iscsi_session_teardown); 1335EXPORT_SYMBOL_GPL(iscsi_session_teardown);
1330 1336