[openib-general] [PATCHE 02/12] SRP: changing ibsrpdm
Ishai Rabinovitz
ishai at mellanox.co.il
Mon May 1 04:25:46 PDT 2006
Move the destruction of the host and the removal from a list to a function.
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-04-23 14:08:03.000000000 +0300
+++ last_stable/drivers/infiniband/ulp/srp/ib_srp.c 2006-04-24 10:47:00.000000000 +0300
@@ -344,6 +344,16 @@ static void srp_disconnect_target(struct
wait_for_completion(&target->done);
}
+static void destruct_scsi_host_and_target(struct srp_target_port *target, int disconnect_target)
+{
+ scsi_remove_host(target->scsi_host);
+ if (disconnect_target)
+ srp_disconnect_target(target);
+ ib_destroy_cm_id(target->cm_id);
+ srp_free_target_ib(target);
+ scsi_host_put(target->scsi_host);
+}
+
static void srp_remove_work(void *target_ptr)
{
struct srp_target_port *target = target_ptr;
@@ -357,10 +374,7 @@ static void srp_remove_work(void *target
list_del(&target->list);
mutex_unlock(&target->srp_host->target_mutex);
- scsi_remove_host(target->scsi_host);
- ib_destroy_cm_id(target->cm_id);
- srp_free_target_ib(target);
- scsi_host_put(target->scsi_host);
+ destruct_scsi_host_and_target(target, 0);
/* And another put to really free the target port... */
scsi_host_put(target->scsi_host);
}
@@ -1734,13 +1746,8 @@ static void srp_remove_one(struct ib_dev
flush_scheduled_work();
list_for_each_entry_safe(target, tmp_target,
- &host->target_list, list) {
- scsi_remove_host(target->scsi_host);
- srp_disconnect_target(target);
- ib_destroy_cm_id(target->cm_id);
- srp_free_target_ib(target);
- scsi_host_put(target->scsi_host);
- }
+ &host->target_list, list)
+ destruct_scsi_host_and_target(target, 1);
ib_dereg_mr(host->mr);
ib_dealloc_pd(host->pd);
--
Ishai Rabinovitz
More information about the general
mailing list