aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/scsi/libiscsi.c8
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c10
2 files changed, 9 insertions, 9 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
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 147c854e1d4d..8717ff51ba4b 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -228,13 +228,11 @@ static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid)
228static void iscsi_session_release(struct device *dev) 228static void iscsi_session_release(struct device *dev)
229{ 229{
230 struct iscsi_cls_session *session = iscsi_dev_to_session(dev); 230 struct iscsi_cls_session *session = iscsi_dev_to_session(dev);
231 struct iscsi_transport *transport = session->transport;
232 struct Scsi_Host *shost; 231 struct Scsi_Host *shost;
233 232
234 shost = iscsi_session_to_shost(session); 233 shost = iscsi_session_to_shost(session);
235 scsi_host_put(shost); 234 scsi_host_put(shost);
236 kfree(session); 235 kfree(session);
237 module_put(transport->owner);
238} 236}
239 237
240static int iscsi_is_session_dev(const struct device *dev) 238static int iscsi_is_session_dev(const struct device *dev)
@@ -305,13 +303,11 @@ iscsi_create_session(struct Scsi_Host *shost,
305 struct iscsi_cls_session *session; 303 struct iscsi_cls_session *session;
306 int err; 304 int err;
307 305
308 if (!try_module_get(transport->owner))
309 return NULL;
310
311 session = kzalloc(sizeof(*session) + transport->sessiondata_size, 306 session = kzalloc(sizeof(*session) + transport->sessiondata_size,
312 GFP_KERNEL); 307 GFP_KERNEL);
313 if (!session) 308 if (!session)
314 goto module_put; 309 return NULL;
310
315 session->transport = transport; 311 session->transport = transport;
316 session->recovery_tmo = 120; 312 session->recovery_tmo = 120;
317 INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 313 INIT_WORK(&session->recovery_work, session_recovery_timedout, session);
@@ -349,8 +345,6 @@ iscsi_create_session(struct Scsi_Host *shost,
349 345
350free_session: 346free_session:
351 kfree(session); 347 kfree(session);
352module_put:
353 module_put(transport->owner);
354 return NULL; 348 return NULL;
355} 349}
356 350