Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752250AbeANJtV (ORCPT + 1 other); Sun, 14 Jan 2018 04:49:21 -0500 Received: from mail-wr0-f176.google.com ([209.85.128.176]:39461 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeANJtU (ORCPT ); Sun, 14 Jan 2018 04:49:20 -0500 X-Google-Smtp-Source: ACJfBovHnjH/neYsMbMmQwb42mkPR7/yu8T5cW0HmC/xqyhsxH8ITFn4nTWLgmHMO4MoLYc9txveYw== Subject: Re: [PATCH V3 2/2] nvme-pci: fix the timeout case when reset is ongoing To: Jianchao Wang , keith.busch@intel.com, axboe@fb.com, hch@lst.de Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <1515647268-1717-1-git-send-email-jianchao.w.wang@oracle.com> <1515647268-1717-3-git-send-email-jianchao.w.wang@oracle.com> From: Sagi Grimberg Message-ID: <33e5eb7d-b731-5f13-1cdf-faf3be508c93@grimberg.me> Date: Sun, 14 Jan 2018 11:49:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1515647268-1717-3-git-send-email-jianchao.w.wang@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index e477c35..0530432 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -1212,19 +1212,26 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) > } > > /* > - * Shutdown immediately if controller times out while starting. The > - * reset work will see the pci device disabled when it gets the forced > - * cancellation error. All outstanding requests are completed on > - * shutdown, so we return BLK_EH_HANDLED. > + * There could be two kinds of expired reqs when reset is ongoing. > + * - Outstanding IO or admin requests from previous work before the > + * nvme_reset_work invokes nvme_dev_disable. Handle them as the > + * nvme_cancel_request. > + * - Outstanding admin requests from the initializing procedure. > + * Set NVME_REQ_CANCELLED flag on them, then nvme_reset_work will > + * see the error, then disable the device and remove the ctrl. > */ > - if (dev->ctrl.state == NVME_CTRL_RESETTING) { > - dev_warn(dev->ctrl.device, > - "I/O %d QID %d timeout, disable controller\n", > - req->tag, nvmeq->qid); > - nvme_dev_disable(dev, false); > + switch (dev->ctrl.state) { > + case NVME_CTRL_RESET_PREPARE: > + nvme_req(req)->status = NVME_SC_ABORT_REQ; > + return BLK_EH_HANDLED; > + case NVME_CTRL_RESETTING: > + WARN_ON_ONCE(nvmeq->qid); > nvme_req(req)->flags |= NVME_REQ_CANCELLED; > return BLK_EH_HANDLED; > + default: > + break; > } > + Indentation is off...