public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@suse.de>
Cc: Hannes Reinecke <hare@suse.de>, Julia Lawall <julia@diku.dk>,
	linux-scsi@vger.kernel.org, joe@perches.com,
	James Smart <James.Smart@Emulex.Com>
Subject: [PATCH v2] scsi: Remove QUEUE_FLAG_REENTER from SCSI code
Date: Tue, 5 Oct 2010 11:00:44 +0200	[thread overview]
Message-ID: <20101005090043.GA18744@schmichrtp.mainz.de.ibm.com> (raw)
In-Reply-To: <20101004134700.GA12628@schmichrtp.mainz.de.ibm.com>

From: Christof Schmitt <christof.schmitt@de.ibm.com>

fc_bsg_goose_queue is only called from fc_remote_port_add which
already requires to be run from thread context. For this case simply
replace fc_bsg_goose_queue with a call to blk_run_queue.

The code in scsi_run_queue needs a mechanism to avoid recursing
through
scsi_run_queue->blk_run_queue->scsi_request_fn->scsi_dispatch_cmd
->scsi_queue_insert->scsi_run_queue for each entry in the
starved_list. Instead of using QUEUE_FLAG_PLUGGED, always defer
running the queue for starved devices to the block layer workqueue.

Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
 drivers/scsi/scsi_lib.c          |   17 +++--------------
 drivers/scsi/scsi_transport_fc.c |   34 ++--------------------------------
 2 files changed, 5 insertions(+), 46 deletions(-)

--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -411,8 +411,6 @@ static void scsi_run_queue(struct reques
 	list_splice_init(&shost->starved_list, &starved_list);
 
 	while (!list_empty(&starved_list)) {
-		int flagset;
-
 		/*
 		 * As long as shost is accepting commands and we have
 		 * starved queues, call blk_run_queue. scsi_request_fn
@@ -435,20 +433,11 @@ static void scsi_run_queue(struct reques
 			continue;
 		}
 
-		spin_unlock(shost->host_lock);
-
 		spin_lock(sdev->request_queue->queue_lock);
-		flagset = test_bit(QUEUE_FLAG_REENTER, &q->queue_flags) &&
-				!test_bit(QUEUE_FLAG_REENTER,
-					&sdev->request_queue->queue_flags);
-		if (flagset)
-			queue_flag_set(QUEUE_FLAG_REENTER, sdev->request_queue);
-		__blk_run_queue(sdev->request_queue);
-		if (flagset)
-			queue_flag_clear(QUEUE_FLAG_REENTER, sdev->request_queue);
+		queue_flag_set(QUEUE_FLAG_PLUGGED, sdev->request_queue);
+		kblockd_schedule_work(sdev->request_queue,
+				      &sdev->request_queue->unplug_work);
 		spin_unlock(sdev->request_queue->queue_lock);
-
-		spin_lock(shost->host_lock);
 	}
 	/* put any unprocessed entries back */
 	list_splice(&starved_list, &shost->starved_list);
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -50,7 +50,6 @@ static int fc_vport_setup(struct Scsi_Ho
 static int fc_bsg_hostadd(struct Scsi_Host *, struct fc_host_attrs *);
 static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *);
 static void fc_bsg_remove(struct request_queue *);
-static void fc_bsg_goose_queue(struct fc_rport *);
 
 /*
  * Redefine so that we can have same named attributes in the
@@ -2737,7 +2736,8 @@ fc_remote_port_add(struct Scsi_Host *sho
 					spin_unlock_irqrestore(shost->host_lock,
 							flags);
 
-				fc_bsg_goose_queue(rport);
+				if (rport->rqst_q)
+					blk_run_queue(rport->rqst_q);
 
 				return rport;
 			}
@@ -3752,36 +3752,6 @@ fail_host_msg:
 	return FC_DISPATCH_UNLOCKED;
 }
 
-
-/*
- * fc_bsg_goose_queue - restart rport queue in case it was stopped
- * @rport:	rport to be restarted
- */
-static void
-fc_bsg_goose_queue(struct fc_rport *rport)
-{
-	int flagset;
-	unsigned long flags;
-
-	if (!rport->rqst_q)
-		return;
-
-	get_device(&rport->dev);
-
-	spin_lock_irqsave(rport->rqst_q->queue_lock, flags);
-	flagset = test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags) &&
-		  !test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags);
-	if (flagset)
-		queue_flag_set(QUEUE_FLAG_REENTER, rport->rqst_q);
-	__blk_run_queue(rport->rqst_q);
-	if (flagset)
-		queue_flag_clear(QUEUE_FLAG_REENTER, rport->rqst_q);
-	spin_unlock_irqrestore(rport->rqst_q->queue_lock, flags);
-
-	put_device(&rport->dev);
-}
-
-
 /**
  * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
  * @q:		rport request queue

      reply	other threads:[~2010-10-05  9:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-28 17:11 question about drivers/scsi/scsi_transport_fc.c Julia Lawall
2010-09-02 10:53 ` Christof Schmitt
2010-09-02 13:39   ` Hannes Reinecke
2010-09-02 14:28     ` Christof Schmitt
2010-09-02 15:01       ` [PATCH] scsi: Remove QUEUE_FLAG_REENTER from SCSI code Christof Schmitt
2010-09-27  7:58         ` James Bottomley
2010-10-04 13:47           ` Christof Schmitt
2010-10-05  9:00             ` Christof Schmitt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101005090043.GA18744@schmichrtp.mainz.de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=James.Bottomley@suse.de \
    --cc=James.Smart@Emulex.Com \
    --cc=hare@suse.de \
    --cc=joe@perches.com \
    --cc=julia@diku.dk \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox