linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY
@ 2017-12-07 22:56 Bart Van Assche
  2017-12-08  2:12 ` Martin K. Petersen
  2017-12-08  2:51 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-12-07 22:56 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Douglas Gilbert, Christoph Hellwig,
	Hannes Reinecke, Johannes Thumshirn

Although it is important to be able to trigger the code in the SCSI
core for SCSI_MLQUEUE_HOST_BUSY handling, currently it is
nontrivial to trigger that code. Hence this patch that adds a new
error injection option to the scsi_debug driver for making the
.queue_rq() implementation of this driver return
SCSI_MLQUEUE_HOST_BUSY.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_debug.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 9833850a53df..4b87e94e6611 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -161,12 +161,14 @@ static const char *sdebug_version_date = "20160430";
 #define SDEBUG_OPT_N_WCE		0x1000
 #define SDEBUG_OPT_RESET_NOISE		0x2000
 #define SDEBUG_OPT_NO_CDB_NOISE		0x4000
+#define SDEBUG_OPT_HOST_BUSY		0x8000
 #define SDEBUG_OPT_ALL_NOISE (SDEBUG_OPT_NOISE | SDEBUG_OPT_Q_NOISE | \
 			      SDEBUG_OPT_RESET_NOISE)
 #define SDEBUG_OPT_ALL_INJECTING (SDEBUG_OPT_RECOVERED_ERR | \
 				  SDEBUG_OPT_TRANSPORT_ERR | \
 				  SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR | \
-				  SDEBUG_OPT_SHORT_TRANSFER)
+				  SDEBUG_OPT_SHORT_TRANSFER | \
+				  SDEBUG_OPT_HOST_BUSY)
 /* When "every_nth" > 0 then modulo "every_nth" commands:
  *   - a missing response is simulated if SDEBUG_OPT_TIMEOUT is set
  *   - a RECOVERED_ERROR is simulated on successful read and write
@@ -282,6 +284,7 @@ struct sdebug_queued_cmd {
 	unsigned int inj_dif:1;
 	unsigned int inj_dix:1;
 	unsigned int inj_short:1;
+	unsigned int inj_host_busy:1;
 };
 
 struct sdebug_queue {
@@ -3995,6 +3998,7 @@ static void setup_inject(struct sdebug_queue *sqp,
 	sqcp->inj_dif = !!(SDEBUG_OPT_DIF_ERR & sdebug_opts);
 	sqcp->inj_dix = !!(SDEBUG_OPT_DIX_ERR & sdebug_opts);
 	sqcp->inj_short = !!(SDEBUG_OPT_SHORT_TRANSFER & sdebug_opts);
+	sqcp->inj_host_busy = !!(SDEBUG_OPT_HOST_BUSY & sdebug_opts);
 }
 
 /* Complete the processing of the thread that queued a SCSI command to this
@@ -5278,6 +5282,12 @@ static bool fake_timeout(struct scsi_cmnd *scp)
 	return false;
 }
 
+static bool fake_host_busy(struct scsi_cmnd *scp)
+{
+	return (sdebug_opts & SDEBUG_OPT_HOST_BUSY) &&
+		(atomic_read(&sdebug_cmnd_count) % abs(sdebug_every_nth)) == 0;
+}
+
 static int scsi_debug_queuecommand(struct Scsi_Host *shost,
 				   struct scsi_cmnd *scp)
 {
@@ -5320,6 +5330,8 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost,
 			sdev_printk(KERN_INFO, sdp, "%s: cmd %s\n", my_name,
 				    b);
 	}
+	if (fake_host_busy(scp))
+		return SCSI_MLQUEUE_HOST_BUSY;
 	has_wlun_rl = (sdp->lun == SCSI_W_LUN_REPORT_LUNS);
 	if (unlikely((sdp->lun >= sdebug_max_luns) && !has_wlun_rl))
 		goto err_out;
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY
  2017-12-07 22:56 [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY Bart Van Assche
@ 2017-12-08  2:12 ` Martin K. Petersen
  2017-12-08  2:46   ` Douglas Gilbert
  2017-12-08  2:51 ` Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2017-12-08  2:12 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Douglas Gilbert, Christoph Hellwig, Hannes Reinecke,
	Johannes Thumshirn


Bart,

> Although it is important to be able to trigger the code in the SCSI
> core for SCSI_MLQUEUE_HOST_BUSY handling, currently it is nontrivial
> to trigger that code. Hence this patch that adds a new error injection
> option to the scsi_debug driver for making the .queue_rq()
> implementation of this driver return SCSI_MLQUEUE_HOST_BUSY.

This looks good to me. Doug?

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY
  2017-12-08  2:12 ` Martin K. Petersen
@ 2017-12-08  2:46   ` Douglas Gilbert
  0 siblings, 0 replies; 4+ messages in thread
From: Douglas Gilbert @ 2017-12-08  2:46 UTC (permalink / raw)
  To: Martin K. Petersen, Bart Van Assche
  Cc: James E . J . Bottomley, linux-scsi, Christoph Hellwig,
	Hannes Reinecke, Johannes Thumshirn

On 2017-12-07 09:12 PM, Martin K. Petersen wrote:
> 
> Bart,
> 
>> Although it is important to be able to trigger the code in the SCSI
>> core for SCSI_MLQUEUE_HOST_BUSY handling, currently it is nontrivial
>> to trigger that code. Hence this patch that adds a new error injection
>> option to the scsi_debug driver for making the .queue_rq()
>> implementation of this driver return SCSI_MLQUEUE_HOST_BUSY.
> 
> This looks good to me. Doug?

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY
  2017-12-07 22:56 [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY Bart Van Assche
  2017-12-08  2:12 ` Martin K. Petersen
@ 2017-12-08  2:51 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-12-08  2:51 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Douglas Gilbert, Christoph Hellwig, Hannes Reinecke,
	Johannes Thumshirn


Bart,

> Although it is important to be able to trigger the code in the SCSI
> core for SCSI_MLQUEUE_HOST_BUSY handling, currently it is
> nontrivial to trigger that code. Hence this patch that adds a new
> error injection option to the scsi_debug driver for making the
> .queue_rq() implementation of this driver return
> SCSI_MLQUEUE_HOST_BUSY.

Applied to 4.16/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-08  2:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 22:56 [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY Bart Van Assche
2017-12-08  2:12 ` Martin K. Petersen
2017-12-08  2:46   ` Douglas Gilbert
2017-12-08  2:51 ` 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).