From: Christoph Hellwig <hch@infradead.org>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 6/6] scsi: remove a useless get/put_device pair in scsi_requeue_command
Date: Thu, 06 Feb 2014 10:43:12 -0800 [thread overview]
Message-ID: <20140206184418.178186483@bombadil.infradead.org> (raw)
In-Reply-To: 20140206184306.997538898@bombadil.infradead.org
[-- Attachment #1: 0006-scsi-remove-a-useless-get-put_device-pair-in-scsi_re.patch --]
[-- Type: text/plain, Size: 1875 bytes --]
Avoid a spurious device get/put cycle by using scsi_put_command and folding
scsi_unprep_request into scsi_requeue_command.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/scsi/scsi_lib.c | 35 +++--------------------------------
1 file changed, 3 insertions(+), 32 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 91ca414..9350691 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -75,29 +75,6 @@ struct kmem_cache *scsi_sdb_cache;
*/
#define SCSI_QUEUE_DELAY 3
-/*
- * Function: scsi_unprep_request()
- *
- * Purpose: Remove all preparation done for a request, including its
- * associated scsi_cmnd, so that it can be requeued.
- *
- * Arguments: req - request to unprepare
- *
- * Lock status: Assumed that no locks are held upon entry.
- *
- * Returns: Nothing.
- */
-static void scsi_unprep_request(struct request *req)
-{
- struct scsi_cmnd *cmd = req->special;
-
- blk_unprep_request(req);
- req->special = NULL;
-
- scsi_put_command(cmd);
- put_device(&cmd->device->sdev_gendev);
-}
-
/**
* __scsi_queue_insert - private queue insertion
* @cmd: The SCSI command being requeued
@@ -503,16 +480,10 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
struct request *req = cmd->request;
unsigned long flags;
- /*
- * We need to hold a reference on the device to avoid the queue being
- * killed after the unlock and before scsi_run_queue is invoked which
- * may happen because scsi_unprep_request() puts the command which
- * releases its reference on the device.
- */
- get_device(&sdev->sdev_gendev);
-
spin_lock_irqsave(q->queue_lock, flags);
- scsi_unprep_request(req);
+ blk_unprep_request(req);
+ req->special = NULL;
+ scsi_put_command(cmd);
blk_requeue_request(q, req);
spin_unlock_irqrestore(q->queue_lock, flags);
--
1.7.10.4
next prev 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 ` [PATCH 4/6] scsi: remove a useless get/put_device pair in scsi_request_fn Christoph Hellwig
2014-02-12 11:38 ` 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 ` Christoph Hellwig [this message]
2014-02-12 11:40 ` [PATCH 6/6] scsi: remove a useless get/put_device pair in scsi_requeue_command 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=20140206184418.178186483@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=James.Bottomley@HansenPartnership.com \
--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 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.