From 0a0a3483f2213172c538d76f1e2561622c6b4695 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Mon, 30 Jun 2008 17:11:41 -0500 Subject: [PATCH 03/12] libfc: fix locking in tt.rport_lookup_create paths 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 --- drivers/scsi/libfc/fc_disc.c | 7 +++++++ drivers/scsi/libfc/fc_lport.c | 6 ++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index 92c069c..95133f2 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c @@ -1014,7 +1014,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); rport = lp->tt.rport_lookup_create(lp, &ids); + spin_lock_bh(&lp->fl_lock); if (!rport) goto err; rp = rport->dd_data; diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index f5c2aae..96643b8 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -182,7 +182,13 @@ 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); rport = lp->tt.rport_lookup_create(lp, &ids); + spin_lock_bh(&lp->fl_lock); if (rport) { if (lp->ptp_rp) { rp = lp->ptp_rp->dd_data; -- 1.5.4.1