[openib-general] SRP: [PATCH] Releasing the scsi_host when unloading
Ishai Rabinovitz
ishai at mellanox.co.il
Sun May 14 06:09:03 PDT 2006
On Sun, May 14, 2006 at 02:02:01PM +0300, Ishai Rabinovitz wrote:
> Hi,
>
> After loading ib_srp module, adding a target and then unloading the ib_srp
> target the scsi_host directory in /sys/class/scsi_host/ still exists.
> It looks like the srp code does not release the scsi_host it had allocated.
>
> After examining the code I found out that when executing srp_remove_work
> (the removal of one target) scsi_host_put is called twice, but when unloading
> the module in srp_remove_one scsi_host_put is called only once.
>
> It looks like the correct thing is to execute scsi_host_put twice (once for
> the call to scsi_add_host and once for the call to scsi_host_alloc).
>
> So, I suggest the next patch:
Forgot to sign. Here it is again with the Signed-off-by line.
Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>
--------------------------------------------------------------------------------
Index: last_stable/drivers/infiniband/ulp/srp/ib_srp.c
===================================================================
--- last_stable.orig/drivers/infiniband/ulp/srp/ib_srp.c 2006-05-14 13:09:23.000000000 +0300
+++ last_stable/drivers/infiniband/ulp/srp/ib_srp.c 2006-05-14 13:25:48.000000000 +0300
@@ -357,7 +357,6 @@ static void srp_remove_work(void *target
spin_lock_irq(target->scsi_host->host_lock);
if (target->state != SRP_TARGET_DEAD) {
spin_unlock_irq(target->scsi_host->host_lock);
- scsi_host_put(target->scsi_host);
return;
}
target->state = SRP_TARGET_REMOVED;
@@ -1790,6 +1789,11 @@ static void srp_remove_one(struct ib_dev
srp_disconnect_target(target);
ib_destroy_cm_id(target->cm_id);
srp_free_target_ib(target);
+ /*
+ * We need 2 scsi_host_put becuase there are two get:
+ * in scsi_host_alloc and in scsi_add_host
+ */
+ scsi_host_put(target->scsi_host);
scsi_host_put(target->scsi_host);
}
More information about the general
mailing list