[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-scsi
Subject:    [PATCH 03/13] libfc: fix locking in tt.rport_lookup_create paths
From:       michaelc () cs ! wisc ! edu
Date:       2008-06-29 18:23:53
Message-ID: 1214763843-5548-4-git-send-email-michaelc () cs ! wisc ! edu
[Download RAW message or body]

From: Mike Christie <michaelc@cs.wisc.edu>

In some code paths we had the fl_lock when calling
tt.rport_lookup_create. tt.rport_lookup_create can sleep if
it needs to create a new rport (fc class uses GFP_KERNEL
for example), so we need to have the spin locks dropped.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
 drivers/scsi/libfc/fc_disc.c  |    7 +++++++
 drivers/scsi/libfc/fc_lport.c |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 45210c3..a1b5171 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -907,7 +907,14 @@ static void fc_disc_enter_dns(struct fc_lport *lp)
 		/*
 		 * Set up remote port to directory server.
 		 */
+
+		/*
+		 * we are called with the fl_lock, but if rport_lookup_create
+		 * needs to create a rport then it will sleep.
+		 */
+		spin_unlock_bh(&lp->fl_lock);
 		rp = lp->tt.rport_lookup_create(lp, &ids);
+		spin_lock_bh(&lp->fl_lock);
 		if (!rp)
 			goto err;
 		lp->tt.sess_init(lp, rp);
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index e3eae92..a7ffab7 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -177,7 +177,14 @@ static void fc_lport_ptp_setup(struct fc_lport *lp,
 		.node_name = remote_wwnn,
 	};
 
+
+	/*
+	 * if we have to create a rport the fc class can sleep so we must
+	 * drop the lock here
+	 */
+	spin_unlock_bh(&lp->fl_lock);
 	rp = lp->tt.rport_lookup_create(lp, &ids);
+	spin_lock_bh(&lp->fl_lock);
 	if (rp) {
 		if (lp->fl_ptp_rp)
 			lp->tt.rport_release(lp->fl_ptp_rp);
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic