* [PATCH] scsi-mq: Always unprepare before requeuing a request
@ 2017-08-03 21:40 Bart Van Assche
2017-08-04 8:06 ` Damien Le Moal
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bart Van Assche @ 2017-08-03 21:40 UTC (permalink / raw)
To: Martin K . Petersen, James E . J . Bottomley
Cc: linux-scsi, Bart Van Assche, Christoph Hellwig, Hannes Reinecke,
Damien Le Moal, Johannes Thumshirn, stable
One of the two scsi-mq functions that requeue a request unprepares
a request before requeueing (scsi_io_completion()) but the other
function not (__scsi_queue_insert()). Make sure that a request is
unprepared before requeuing it.
Fixes: commit d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: <stable@vger.kernel.org>
---
drivers/scsi/scsi_lib.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4a2f705cdb14..c7514f3b444a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -44,6 +44,8 @@ static struct kmem_cache *scsi_sense_cache;
static struct kmem_cache *scsi_sense_isadma_cache;
static DEFINE_MUTEX(scsi_sense_cache_mutex);
+static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd);
+
static inline struct kmem_cache *
scsi_select_sense_cache(bool unchecked_isa_dma)
{
@@ -140,6 +142,12 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
{
struct scsi_device *sdev = cmd->device;
+ if (cmd->request->rq_flags & RQF_DONTPREP) {
+ cmd->request->rq_flags &= ~RQF_DONTPREP;
+ scsi_mq_uninit_cmd(cmd);
+ } else {
+ WARN_ON_ONCE(true);
+ }
blk_mq_requeue_request(cmd->request, true);
put_device(&sdev->sdev_gendev);
}
@@ -995,8 +1003,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
* A new command will be prepared and issued.
*/
if (q->mq_ops) {
- cmd->request->rq_flags &= ~RQF_DONTPREP;
- scsi_mq_uninit_cmd(cmd);
scsi_mq_requeue_cmd(cmd);
} else {
scsi_release_buffers(cmd);
--
2.13.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi-mq: Always unprepare before requeuing a request
2017-08-03 21:40 [PATCH] scsi-mq: Always unprepare before requeuing a request Bart Van Assche
@ 2017-08-04 8:06 ` Damien Le Moal
2017-08-05 11:36 ` Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Damien Le Moal @ 2017-08-04 8:06 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
Cc: linux-scsi, Christoph Hellwig, Hannes Reinecke,
Johannes Thumshirn, stable
On 8/4/17 06:40, Bart Van Assche wrote:
> One of the two scsi-mq functions that requeue a request unprepares
> a request before requeueing (scsi_io_completion()) but the other
> function not (__scsi_queue_insert()). Make sure that a request is
> unprepared before requeuing it.
>
> Fixes: commit d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Damien Le Moal <damien.lemoal@wdc.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> Cc: <stable@vger.kernel.org>
> ---
> drivers/scsi/scsi_lib.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 4a2f705cdb14..c7514f3b444a 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -44,6 +44,8 @@ static struct kmem_cache *scsi_sense_cache;
> static struct kmem_cache *scsi_sense_isadma_cache;
> static DEFINE_MUTEX(scsi_sense_cache_mutex);
>
> +static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd);
> +
> static inline struct kmem_cache *
> scsi_select_sense_cache(bool unchecked_isa_dma)
> {
> @@ -140,6 +142,12 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
> {
> struct scsi_device *sdev = cmd->device;
>
> + if (cmd->request->rq_flags & RQF_DONTPREP) {
> + cmd->request->rq_flags &= ~RQF_DONTPREP;
> + scsi_mq_uninit_cmd(cmd);
> + } else {
> + WARN_ON_ONCE(true);
> + }
> blk_mq_requeue_request(cmd->request, true);
> put_device(&sdev->sdev_gendev);
> }
> @@ -995,8 +1003,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
> * A new command will be prepared and issued.
> */
> if (q->mq_ops) {
> - cmd->request->rq_flags &= ~RQF_DONTPREP;
> - scsi_mq_uninit_cmd(cmd);
> scsi_mq_requeue_cmd(cmd);
> } else {
> scsi_release_buffers(cmd);
>
Tested-by: Damien Le Moal <damien.lemoal@wdc.com>
This patch is needed for the V2 of the series "Zoned block device
support fixes" that I sent.
Best regards.
--
Damien Le Moal,
Western Digital
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi-mq: Always unprepare before requeuing a request
2017-08-03 21:40 [PATCH] scsi-mq: Always unprepare before requeuing a request Bart Van Assche
2017-08-04 8:06 ` Damien Le Moal
@ 2017-08-05 11:36 ` Christoph Hellwig
2017-08-07 7:33 ` Johannes Thumshirn
2017-08-07 17:49 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-05 11:36 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
Christoph Hellwig, Hannes Reinecke, Damien Le Moal,
Johannes Thumshirn, stable
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi-mq: Always unprepare before requeuing a request
2017-08-03 21:40 [PATCH] scsi-mq: Always unprepare before requeuing a request Bart Van Assche
2017-08-04 8:06 ` Damien Le Moal
2017-08-05 11:36 ` Christoph Hellwig
@ 2017-08-07 7:33 ` Johannes Thumshirn
2017-08-07 17:49 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2017-08-07 7:33 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
Christoph Hellwig, Hannes Reinecke, Damien Le Moal, stable
Thanks Bart,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi-mq: Always unprepare before requeuing a request
2017-08-03 21:40 [PATCH] scsi-mq: Always unprepare before requeuing a request Bart Van Assche
` (2 preceding siblings ...)
2017-08-07 7:33 ` Johannes Thumshirn
@ 2017-08-07 17:49 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-08-07 17:49 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
Christoph Hellwig, Hannes Reinecke, Damien Le Moal,
Johannes Thumshirn, stable
Bart,
> One of the two scsi-mq functions that requeue a request unprepares a
> request before requeueing (scsi_io_completion()) but the other
> function not (__scsi_queue_insert()). Make sure that a request is
> unprepared before requeuing it.
Applied to 4.13/scsi-fixes. Thanks much!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-07 17:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 21:40 [PATCH] scsi-mq: Always unprepare before requeuing a request Bart Van Assche
2017-08-04 8:06 ` Damien Le Moal
2017-08-05 11:36 ` Christoph Hellwig
2017-08-07 7:33 ` Johannes Thumshirn
2017-08-07 17:49 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).