From patchwork Mon Jan 8 18:50:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10150319 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 0EF6160210 for ; Mon, 8 Jan 2018 18:50:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BA92289D7 for ; Mon, 8 Jan 2018 18:50:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10498289DD; Mon, 8 Jan 2018 18:50:37 +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 A7CCA289D7 for ; Mon, 8 Jan 2018 18:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756003AbeAHSu2 (ORCPT ); Mon, 8 Jan 2018 13:50:28 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:9748 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755988AbeAHSuS (ORCPT ); Mon, 8 Jan 2018 13:50:18 -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=1515437419; x=1546973419; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=z5mbexr1P77cRpROb2bhVMBAdyPI2f1PEC18KjGTpZ4=; b=VrwtRQV4sqwYPwVOO6Aolq6yctf/j5WmXhNaJk9pa1Ge3/5tteVwfy72 bb4GO7zvur5MYIFhNMTfbHImRC2dXPhzitA4iQ2t5bLL65/iWrh60pzYK l6XG8rocWrCZCRd6CRhKhDlrscSijOZRb39lGPFEXqNlAYqSLI/lA8j5R 3ai6EGWV5NXWurKAzK2DCRNus7TVFFovZkuiWxcihAIudk2WCKiOh/rXL BxXjZzAaLS1w3Gse0gCqtytYoIXi7/0LNLRQZdbg19pb2C+gLG0fsbY/e fvilo4BwFnl/HZAmvdt/Yv2NYlqR8f5f6Sv2ess6MiVvB1b2TtatK8lJw w==; X-IronPort-AV: E=Sophos;i="5.46,332,1511798400"; d="scan'208";a="68074223" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 09 Jan 2018 02:50:13 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 08 Jan 2018 10:45:47 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 08 Jan 2018 10:50:13 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Jason Gunthorpe , Doug Ledford , linux-scsi@vger.kernel.org, linux-rdma@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Johannes Thumshirn , Ming Lei Subject: [PATCH 3/4] scsi: Avoid that .queuecommand() gets called for a quiesced SCSI device Date: Mon, 8 Jan 2018 10:50:10 -0800 Message-Id: <20180108185011.30018-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108185011.30018-1-bart.vanassche@wdc.com> References: <20180108185011.30018-1-bart.vanassche@wdc.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several SCSI transport and LLD drivers surround code that does not tolerate concurrent calls of .queuecommand() with scsi_target_block() / scsi_target_unblock(). These last two functions use blk_mq_quiesce_queue() / blk_mq_unquiesce_queue() for scsi-mq request queues to prevent concurrent .queuecommand() calls. However, that is not sufficient to prevent .queuecommand() calls from scsi_send_eh_cmnd(). Hence surround the .queuecommand() call from the SCSI error handler with blk_wait_if_quiesced() / blk_finish_wait_if_quiesced(). Note: converting the .queuecommand() call in scsi_send_eh_cmnd() into code that calls blk_get_request(), e.g. scsi_execute_req(), is not an option since scsi_send_eh_cmnd() can be called if all requests are allocated and if no requests will make progress without aborting any of these requests. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Ming Lei Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 62b56de38ae8..5af3de1731a5 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1016,6 +1016,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd, { struct scsi_device *sdev = scmd->device; struct Scsi_Host *shost = sdev->host; + struct request_queue *q = sdev->request_queue; DECLARE_COMPLETION_ONSTACK(done); unsigned long timeleft = timeout; struct scsi_eh_save ses; @@ -1028,7 +1029,9 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd, scsi_log_send(scmd); scmd->scsi_done = scsi_eh_done; + blk_wait_if_quiesced(q); rtn = shost->hostt->queuecommand(shost, scmd); + blk_finish_wait_if_quiesced(q); if (rtn) { if (timeleft > stall_for) { scsi_eh_restore_cmnd(scmd, &ses);