From patchwork Thu Jul 19 21:26:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10535371 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 2531460547 for ; Thu, 19 Jul 2018 21:26:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16E7429D39 for ; Thu, 19 Jul 2018 21:26:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ADB129D42; Thu, 19 Jul 2018 21:26:33 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 BC38E29D48 for ; Thu, 19 Jul 2018 21:26:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730679AbeGSWL1 (ORCPT ); Thu, 19 Jul 2018 18:11:27 -0400 Received: from mga09.intel.com ([134.134.136.24]:57058 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbeGSWL1 (ORCPT ); Thu, 19 Jul 2018 18:11:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2018 14:26:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,376,1526367600"; d="scan'208";a="55692142" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.44]) by fmsmga007.fm.intel.com with ESMTP; 19 Jul 2018 14:26:25 -0700 From: Keith Busch To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Cc: linux-nvme@lists.infradead.org, Christoph Hellwig , Jens Axboe , Jianchao Wang , Bart Van Assche , Keith Busch Subject: [PATCH 2/2] scsi: set timed out out mq requests to complete Date: Thu, 19 Jul 2018 15:26:18 -0600 Message-Id: <20180719212618.2406-2-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180719212618.2406-1-keith.busch@intel.com> References: <20180719212618.2406-1-keith.busch@intel.com> 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 The scsi block layer requires requests claimed be the error handling be completed by the error handler. A previous commit allowed completions to proceed for blk-mq, breaking that assumption. This patch prevents completions that may race with the timeout handler by marking the state to complete, restoring the previous behavior. Fixes: 12f5b931 ("blk-mq: Remove generation seqeunce") Signed-off-by: Keith Busch --- Tested using Jianchao's abort injection to scsi_debug described here: https://lore.kernel.org/lkml/a68ad043-26a1-d3d8-2009-504ba4230e0f@oracle.com/ drivers/scsi/scsi_error.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 8932ae81a15a..86ee10b2c775 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -286,6 +286,9 @@ enum blk_eh_timer_return scsi_times_out(struct request *req) enum blk_eh_timer_return rtn = BLK_EH_DONE; struct Scsi_Host *host = scmd->device->host; + if (req->q->mq_ops && blk_mq_mark_complete(req)) + return rtn; + trace_scsi_dispatch_cmd_timeout(scmd); scsi_log_completion(scmd, TIMEOUT_ERROR); @@ -300,7 +303,8 @@ enum blk_eh_timer_return scsi_times_out(struct request *req) set_host_byte(scmd, DID_TIME_OUT); scsi_eh_scmd_add(scmd); } - } + } else if (req->q->mq_ops) + WRITE_ONCE(req->state, MQ_RQ_IN_FLIGHT); return rtn; }