Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp179805pxb; Thu, 12 Aug 2021 13:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2IOMOkNpdm3UiH1UEE29QCm65n9wYT2CxoskXTHxf0UR2Nzgv+hPiq3yXUvLakb8PiqBB X-Received: by 2002:a92:6605:: with SMTP id a5mr355706ilc.15.1628801133407; Thu, 12 Aug 2021 13:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628801133; cv=none; d=google.com; s=arc-20160816; b=ydJDIdJwylrDcpUD1T/uQJa7vA8GNJrj4mwMrzwhFbffj0ii5lcSM6Nj6qqRMYz82q IDsmp40THBx9yyhlYxEwofkdwHTXOy7VQWMS8tSQbYxk5DTCfMwvQrztSGXYOognorv1 2c3Ci3wrlMASRz8RCFXGzR2eexb20Z/tV4zmgxjCHbKhgRIT7grWC5gwPbl40yhOX4eO ejmMNpxHAhnSH4BYIXZCO11H1RZz8JpOGyHUmPUzOks7DBttPAd7D0Fb+/R0KNWQYPFl VsdH6dvfQ7pbJPQjC3jmz/crc4KSKJYEPcOSDD1nogwsma6iJsuiSeK9bhs7BI1RL1ix ZEVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=NWgmDEccyBvUvz6V9WedwFoBsgEY8nM0D4Z4cC7Dw1I=; b=TtpMWKisbbRU01fwm4VjMmqIEGt/+hQ2gfhpZnGsSs4RX7kYdWTJpoEgwb8p+guEbe OxjaUZZ05ZyidXsV532SxY0Y8E4sr+g03rjtMBBlcqEyZkEO2vF7Vv+g4OWyctB1hA38 Bp6BlAk7gkLrSDNfuewWYksdwS1p6T8dNJ8KDqJRGu46lb6+8TQiKFUySGmF57mqiafp vPzK7vMfhl8AClKnEpsPlkHG30hO8QWR322TTgh0Ut06/IjdrGlTLdDVW2h6mh9xzSBd KTeB3Tr/jtoEV4zDPJfOkw/LdV1rDM1L25GcyiWRz5v5D5FVjWZL0Q8L5W6ZgLeIy1Gb EKVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KPAXx1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si3955360iln.130.2021.08.12.13.45.00; Thu, 12 Aug 2021 13:45:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KPAXx1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236800AbhHLUDi (ORCPT + 99 others); Thu, 12 Aug 2021 16:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236813AbhHLUDf (ORCPT ); Thu, 12 Aug 2021 16:03:35 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F4EC061756 for ; Thu, 12 Aug 2021 13:03:09 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id e19so8720445pla.10 for ; Thu, 12 Aug 2021 13:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NWgmDEccyBvUvz6V9WedwFoBsgEY8nM0D4Z4cC7Dw1I=; b=KPAXx1x0ghxtiKWnxWPLcRjyNaCb/MBL5gr9Di8dpaE8YepmpQG2Py4q8Km5krGwtf hd+78annMTSb2H0HMRRSTjqEUs4TihRPMXUVRnMUHRcbUTiVgQ26wUiwkvWpACTGEMqc w9Rql7eM/6wI6QrJYRxBaTdXaU9rCL5Wfk2lvKu4XmGieAfwjinEoU6SObJ0Kh2r6yyx nmntBx+tzxXS5gnEyXFT+0OCEKZnDXgfADScdkkVOwyxICnatOkR5/pws77rEAHtP8L+ GIIw/KqLIR5y7OicfcKxB4kD4DOUs+QEhVPg5J/BQtezR3K/BL8eO2dnFkeh2ixMwXFV n+bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NWgmDEccyBvUvz6V9WedwFoBsgEY8nM0D4Z4cC7Dw1I=; b=QyNgHQj88doAlg0STIJbuyQAbVqfcsuRMHXocM0f8p4He521gmMMz5eLazwOFprzHX Gch3EbmfPctVnX5mevoxfalFwrnXwccMgHJlQRVKfH+cvGGwQYq2UmDtHByQMnKNBV9K 4MiqCVjX7aNk0EXaOPUn0rGKRi2uZRHS4UqvYOg35jveixpLxTu6H3UMPxDhUBdVYRSz bOtykXQJaG0rzMe7nHSuIQXM7vdX7qLA/x/d4VtQ/Qvkpp3aCzxhaDGFFzAZOV3ahXkI Cuc8T+XiL0HT2AqDY8cpwjWNX6/vhDrBN52FAHbY6vytmgRQhj7euT+2l3a02umvn9u7 McEQ== X-Gm-Message-State: AOAM5322JFS5nvSYZMKNoHMselD0MBNyJy3Ndb2FfeC3R4ubtjVCXuux jb7G6DCJG624kvd3Ib7ZTJA= X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr18539852pjr.4.1628798589513; Thu, 12 Aug 2021 13:03:09 -0700 (PDT) Received: from [10.69.44.239] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id l11sm4526447pfd.187.2021.08.12.13.03.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Aug 2021 13:03:09 -0700 (PDT) Subject: Re: [PATCH v4 6/8] nvme-fc: fix controller reset hang during traffic To: Hannes Reinecke , Daniel Wagner , linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, James Smart , Keith Busch , Ming Lei , Sagi Grimberg , Wen Xiong References: <20210802112658.75875-1-dwagner@suse.de> <20210802112658.75875-7-dwagner@suse.de> <79c89923-f586-79e7-6dfd-c15ceb21f569@suse.de> From: James Smart Message-ID: <3d4edf17-2be6-b7c3-a6fd-b439e5e52eab@gmail.com> Date: Thu, 12 Aug 2021 13:03:07 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <79c89923-f586-79e7-6dfd-c15ceb21f569@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/4/2021 12:23 AM, Hannes Reinecke wrote: > On 8/2/21 1:26 PM, Daniel Wagner wrote: >> From: James Smart >> >> commit fe35ec58f0d3 ("block: update hctx map when use multiple maps") >> exposed an issue where we may hang trying to wait for queue freeze >> during I/O. We call blk_mq_update_nr_hw_queues which may attempt to freeze >> the queue. However we never started queue freeze when starting the >> reset, which means that we have inflight pending requests that entered the >> queue that we will not complete once the queue is quiesced. >> >> So start a freeze before we quiesce the queue, and unfreeze the queue >> after we successfully connected the I/O queues (the unfreeze is already >> present in the code). blk_mq_update_nr_hw_queues will be called only >> after we are sure that the queue was already frozen. >> >> This follows to how the pci driver handles resets. >> >> This patch added logic introduced in commit 9f98772ba307 "nvme-rdma: fix >> controller reset hang during traffic". >> >> Signed-off-by: James Smart >> CC: Sagi Grimberg >> [dwagner: call nvme_unfreeze() unconditionally in >> nvme_fc_recreate_io_queues() to match the nvme_start_freeze()] >> Tested-by: Daniel Wagner >> Reviewed-by: Daniel Wagner >> --- >> drivers/nvme/host/fc.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c >> index 133b87db4f1d..b292af0fd655 100644 >> --- a/drivers/nvme/host/fc.c >> +++ b/drivers/nvme/host/fc.c >> @@ -2486,6 +2486,7 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) >> * (but with error status). >> */ >> if (ctrl->ctrl.queue_count > 1) { >> + nvme_start_freeze(&ctrl->ctrl); >> nvme_stop_queues(&ctrl->ctrl); >> nvme_sync_io_queues(&ctrl->ctrl); >> blk_mq_tagset_busy_iter(&ctrl->tag_set, >> @@ -2966,8 +2967,8 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) >> return -ENODEV; >> } >> blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); >> - nvme_unfreeze(&ctrl->ctrl); >> } >> + nvme_unfreeze(&ctrl->ctrl); >> >> ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1); >> if (ret) >> > There still is now an imbalance, as we're always calling > 'nvme_unfreeze()' (irrespective on the number of queues), but will only > call 'nvme_start_freeze()' if we have more than one queue. > > This might lead to an imbalance on the mq_freeze_depth counter. > Wouldn't it be better to move the call to 'nvme_start_freeze()' out of > the if() condition to avoid the imbalance? > > Cheers, Daniel, try this. Moves the location of the freeze and will always pair with the unfreeze. --- fc.c 2021-08-12 12:33:33.273278611 -0700 +++ fc.c.new 2021-08-12 13:01:16.185817238 -0700 @@ -2965,9 +2965,10 @@ nvme_fc_recreate_io_queues(struct nvme_f prior_ioq_cnt, nr_io_queues); nvme_wait_freeze(&ctrl->ctrl); blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues); - nvme_unfreeze(&ctrl->ctrl); } + nvme_unfreeze(&ctrl->ctrl); + return 0; out_delete_hw_queues: @@ -3206,6 +3207,9 @@ nvme_fc_delete_association(struct nvme_f ctrl->iocnt = 0; spin_unlock_irqrestore(&ctrl->lock, flags); + if (ctrl->ctrl.queue_count > 1) + nvme_start_freeze(&ctrl->ctrl); + __nvme_fc_abort_outstanding_ios(ctrl, false); /* kill the aens as they are a separate path */