All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Tejun Heo <tj@kernel.org>, Mike Christie <michaelc@cs.wisc.edu>
Subject: [PATCH 4/6] scsi: remove a useless get/put_device pair in scsi_request_fn
Date: Thu, 06 Feb 2014 10:43:10 -0800	[thread overview]
Message-ID: <20140206184417.890824661@bombadil.infradead.org> (raw)
In-Reply-To: 20140206184306.997538898@bombadil.infradead.org

[-- Attachment #1: 0004-scsi-remove-a-useless-get-put_device-pair-in-scsi_re.patch --]
[-- Type: text/plain, Size: 2084 bytes --]

From: Bart Van Assche <bvanassche@acm.org>

SCSI devices may only be removed by calling scsi_remove_device().
That function must invoke blk_cleanup_queue() before the final put
of sdev->sdev_gendev. Since blk_cleanup_queue() waits for the
block queue to drain and then tears it down, scsi_request_fn cannot
be active anymore after blk_cleanup_queue() has returned and hence
the get_device()/put_device() pair in scsi_request_fn is unnecessary.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
---
 drivers/scsi/scsi_lib.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 500178c..7d35678 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1558,16 +1558,14 @@ static void scsi_softirq_done(struct request *rq)
  * Lock status: IO request lock assumed to be held when called.
  */
 static void scsi_request_fn(struct request_queue *q)
+	__releases(q->queue_lock)
+	__acquires(q->queue_lock)
 {
 	struct scsi_device *sdev = q->queuedata;
 	struct Scsi_Host *shost;
 	struct scsi_cmnd *cmd;
 	struct request *req;
 
-	if(!get_device(&sdev->sdev_gendev))
-		/* We must be tearing the block queue down already */
-		return;
-
 	/*
 	 * To start with, we keep looping until the queue is empty, or until
 	 * the host is no longer able to accept any more requests.
@@ -1656,7 +1654,7 @@ static void scsi_request_fn(struct request_queue *q)
 			goto out_delay;
 	}
 
-	goto out;
+	return;
 
  not_ready:
 	spin_unlock_irq(shost->host_lock);
@@ -1675,12 +1673,6 @@ static void scsi_request_fn(struct request_queue *q)
 out_delay:
 	if (sdev->device_busy == 0)
 		blk_delay_queue(q, SCSI_QUEUE_DELAY);
-out:
-	/* must be careful here...if we trigger the ->remove() function
-	 * we cannot be holding the q lock */
-	spin_unlock_irq(q->queue_lock);
-	put_device(&sdev->sdev_gendev);
-	spin_lock_irq(q->queue_lock);
 }
 
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
-- 
1.7.10.4



  parent reply	other threads:[~2014-02-06 18:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 18:43 [PATCH 0/6] first batch of SCSI data path micro-optimizations Christoph Hellwig
2014-02-06 18:43 ` [PATCH 1/6] scsi: avoid useless free_list lock roundtrips Christoph Hellwig
2014-02-12 10:53   ` Hannes Reinecke
2014-02-06 18:43 ` [PATCH 2/6] scsi: avoid taking host_lock in scsi_run_queue unless nessecary Christoph Hellwig
2014-02-12 11:08   ` Hannes Reinecke
2014-02-12 15:52     ` Christoph Hellwig
2014-02-06 18:43 ` [PATCH 3/6] scsi: do not manipulate device reference counts in scsi_get/put_command Christoph Hellwig
2014-02-12 11:37   ` Hannes Reinecke
2014-02-12 15:58     ` Christoph Hellwig
2014-02-06 18:43 ` Christoph Hellwig [this message]
2014-02-12 11:38   ` [PATCH 4/6] scsi: remove a useless get/put_device pair in scsi_request_fn Hannes Reinecke
2014-02-06 18:43 ` [PATCH 5/6] scsi: remove a useless get/put_device pair in scsi_next_command Christoph Hellwig
2014-02-12 11:39   ` Hannes Reinecke
2014-02-06 18:43 ` [PATCH 6/6] scsi: remove a useless get/put_device pair in scsi_requeue_command Christoph Hellwig
2014-02-12 11:40   ` Hannes Reinecke
2014-02-12 15:58     ` Christoph Hellwig

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=20140206184417.890824661@bombadil.infradead.org \
    --to=hch@infradead.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bvanassche@acm.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    --cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.