From patchwork Thu Dec 7 22:56:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10101223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2EAD960325 for ; Thu, 7 Dec 2017 22:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FDF928897 for ; Thu, 7 Dec 2017 22:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14B7B2889B; Thu, 7 Dec 2017 22:56:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59F0D28897 for ; Thu, 7 Dec 2017 22:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751904AbdLGW4T (ORCPT ); Thu, 7 Dec 2017 17:56:19 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:21328 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750919AbdLGW4T (ORCPT ); Thu, 7 Dec 2017 17:56:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1512687379; x=1544223379; h=from:to:cc:subject:date:message-id; bh=OZI9PoRxKVkRFcBp+1hV75yXGhsQUylt0OdCIUHYLJM=; b=kB6nCTQGyIang6QpXUPxOWMWADm/adYeF4/+9MzNeRU/y35qOdccxO7/ ez09ZKsQeRDSfVe13pvJE2JP9Seb5w072YnSJRVlniFtxBM39u8IVKxrt IV+zqRP7C1kItI0WPGGhcnxrrRRBc/KQsIwa8Dz7OArZJsH28+d3G7yvy Q6PZMrHJlijUfn3uO2WVsI4j7mF+HcA/UFyywojfemPhK9w33J6WTFNLh fhYEivyXDrEcc67jM9usVZ987DOvLA1WwWdbMuGjnvw1YcOfL2dRies0J ji/BnoZUCp23BJChPsKhcuEPolURvCMEDK+2iGYB0jGzj/JALQMl3qZnw A==; X-IronPort-AV: E=Sophos;i="5.45,375,1508774400"; d="scan'208";a="167158430" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 08 Dec 2017 06:56:18 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 07 Dec 2017 14:53:22 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.166.51]) by uls-op-cesaip02.wdc.com with ESMTP; 07 Dec 2017 14:56:19 -0800 From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Douglas Gilbert , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH] scsi_debug: Add support for injecting SCSI_MLQUEUE_HOST_BUSY Date: Thu, 7 Dec 2017 14:56:18 -0800 Message-Id: <20171207225618.3116-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Douglas Gilbert Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Acked-by: Douglas Gilbert --- 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;