From patchwork Wed Jan 10 18:18:16 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: 10155815 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 9CBD8601A1 for ; Wed, 10 Jan 2018 18:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C26285B9 for ; Wed, 10 Jan 2018 18:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87154285C7; Wed, 10 Jan 2018 18:18:59 +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 1B35D285B9 for ; Wed, 10 Jan 2018 18:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752434AbeAJSS5 (ORCPT ); Wed, 10 Jan 2018 13:18:57 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:57238 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbeAJSSS (ORCPT ); Wed, 10 Jan 2018 13:18: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=1515608634; x=1547144634; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=NMyVw+j82WxqKNOXfD+uwhPSK9dbDLpJyhn51G7AZhU=; b=hFd2aMedfYXoG+YKHToryDHpNSzmvG8SFUpDRAkR49lnSB5GSa267e77 aWsrUw6TAoguietS9tC3y7gwVqxC9QuJIEQq9h7RfJBElbDfKHpicxCsE TqH7fdANhbryd/GDOgehMP/v/8na/mRAmfP4jMEpWauVFf9hdwwJxuhIg wZN82jXeA2VTy5yIxKZ7rpXxpnUwA1O+JMy53fqCe5a3DZAzuKrtbT7Fd 6glUEoPgtY42OBQ9wjspyMjZcVzmmIlqIevmcqN8k64BqaaFwCNJzmkKV BhthqxcSvnz7Gf/PRjmpBb4gBcenkuGEZgCaSNqpmeXGpKkEiJMFBP/51 g==; X-IronPort-AV: E=Sophos;i="5.46,341,1511798400"; d="scan'208";a="164728788" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Jan 2018 02:23:54 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 10 Jan 2018 10:13:50 -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; 10 Jan 2018 10:18:18 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Hannes Reinecke , Jason Gunthorpe , Doug Ledford , linux-scsi@vger.kernel.org, linux-rdma@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Ming Lei Subject: [PATCH v2 3/4] scsi: Avoid that .queuecommand() gets called for a quiesced SCSI device Date: Wed, 10 Jan 2018 10:18:16 -0800 Message-Id: <20180110181817.25166-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180110181817.25166-1-bart.vanassche@wdc.com> References: <20180110181817.25166-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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_start_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 Reviewed-by: Hannes Reinecke Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Johannes Thumshirn Cc: Ming Lei --- 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..f7154ea86715 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_start_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);