aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2013-10-26 08:32:30 -0400
committerRoland Dreier <roland@purestorage.com>2013-11-08 17:43:15 -0500
commit9dd69a600a680fab1c9235a644c886d8d6a2da2a (patch)
tree844b8e5cf7e9ff7638eb5b5dd32c40d55c974733 /drivers/infiniband
parent7bb312e4a2f323fa460bbf9f33eeb00b5dabdb6b (diff)
IB/srp: Keep rport as long as the IB transport layer
Keep the rport data structure around after srp_remove_host() has finished until cleanup of the IB transport layer has finished completely. This is necessary because later patches use the rport pointer inside the queuecommand callback. Without this patch accessing the rport from inside a queuecommand callback is racy because srp_remove_host() must be invoked before scsi_remove_host() and because the queuecommand callback could get invoked after srp_remove_host() has finished. In other words, without this patch the queuecommand callback can get invoked after the rport data structure has been freed. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c3
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 11ebf3e7646a..6edab7855f5e 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -528,11 +528,13 @@ static void srp_remove_target(struct srp_target_port *target)
528 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED); 528 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED);
529 529
530 srp_del_scsi_host_attr(target->scsi_host); 530 srp_del_scsi_host_attr(target->scsi_host);
531 srp_rport_get(target->rport);
531 srp_remove_host(target->scsi_host); 532 srp_remove_host(target->scsi_host);
532 scsi_remove_host(target->scsi_host); 533 scsi_remove_host(target->scsi_host);
533 srp_disconnect_target(target); 534 srp_disconnect_target(target);
534 ib_destroy_cm_id(target->cm_id); 535 ib_destroy_cm_id(target->cm_id);
535 srp_free_target_ib(target); 536 srp_free_target_ib(target);
537 srp_rport_put(target->rport);
536 srp_free_req_data(target); 538 srp_free_req_data(target);
537 scsi_host_put(target->scsi_host); 539 scsi_host_put(target->scsi_host);
538} 540}
@@ -2004,6 +2006,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
2004 } 2006 }
2005 2007
2006 rport->lld_data = target; 2008 rport->lld_data = target;
2009 target->rport = rport;
2007 2010
2008 spin_lock(&host->target_lock); 2011 spin_lock(&host->target_lock);
2009 list_add_tail(&target->list, &host->target_list); 2012 list_add_tail(&target->list, &host->target_list);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 84d821b24ec7..2a1768fcc57d 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -153,6 +153,7 @@ struct srp_target_port {
153 u16 io_class; 153 u16 io_class;
154 struct srp_host *srp_host; 154 struct srp_host *srp_host;
155 struct Scsi_Host *scsi_host; 155 struct Scsi_Host *scsi_host;
156 struct srp_rport *rport;
156 char target_name[32]; 157 char target_name[32];
157 unsigned int scsi_id; 158 unsigned int scsi_id;
158 unsigned int sg_tablesize; 159 unsigned int sg_tablesize;