From patchwork Tue Jan 28 16:34:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13952771 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9E9F1DE3C3; Tue, 28 Jan 2025 16:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082110; cv=none; b=qq1lHiXEFCWf4SE2A8BMTy6Gl34o343jsdeD2bjIiYoVfi2PFfDF/FClpzYbrPpFi1UtW3HfOlLMN9FfV9tbgip2f86tbK2NEYK8BXamk+Js47NS6ORHPYKvA0JFfxRNBfHecyIBiRdiw3utaN/AGJoXaxJqXfjhS6w0BfN2HYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082110; c=relaxed/simple; bh=EqUhYMGg7r3msMj02LTUSBZGnT7L9xWRdBClYC5kDdc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vk3EKCgOzcF+lyxi8j1pmtBtClwifQR88xFNFwdGM9DXEjo95HKAENPtEegLMLCubatvZuP9jq2fNxsnZDIwVII/9oZcXFtM8P9fypsmc0i0jQXhHLCM7g4riFgUZukMnv4JosdmpFVOEJGuMjDW58iVJIQ20yeR0rL0+CFApqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tChAcbq7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tChAcbq7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61B3AC4CEE2; Tue, 28 Jan 2025 16:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738082109; bh=EqUhYMGg7r3msMj02LTUSBZGnT7L9xWRdBClYC5kDdc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tChAcbq78A2IK8uEqwPSxE4qq5nLYDCicUs6lftYelHuJSJttZ3QmaOkxr4c0boem a7G053D88tS6k46gqEaXmZzIH+mIn1Epwlo2KG5TClGaNnh+RVnwR6uEJxcZifIkSr XgQAisD/9UMsTi674UP671qj/uwYiMEe/a4WY0RAqy9cMNZ1wIDAiZ7i4LaTzgGueX 0tTpSK2RS+IRaVAp3Eo5/No/D9H0Ndho2KVF1yDYFNIE59J5jjJ4m3kZwZHnAq7hy3 1ZptCHkBqdXQ4nsQSjwaCLGZXFZbldjFXDx6pAlK8fxoAFJIdqsT9MSNOCaB5lGd2X dLxQlxdKaL8Wg== From: Daniel Wagner Date: Tue, 28 Jan 2025 17:34:46 +0100 Subject: [PATCH 1/3] nvme-tcp: rate limit error message in send path Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250128-nvme-misc-fixes-v1-1-40c586581171@kernel.org> References: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> In-Reply-To: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Ming Lei Cc: James Smart , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.2 If a lot of request are in the queue, this message is spamming the logs, thus rate limit it. Signed-off-by: Daniel Wagner --- drivers/nvme/host/tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index dc5bbca58c6dcbce40cfa3de893592d768ebc939..1ed0bc10b2dffe534536b1073abc0302056aa51e 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1257,8 +1257,8 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue) if (ret == -EAGAIN) { ret = 0; } else if (ret < 0) { - dev_err(queue->ctrl->ctrl.device, - "failed to send request %d\n", ret); + dev_err_ratelimited(queue->ctrl->ctrl.device, + "failed to send request %d\n", ret); nvme_tcp_fail_request(queue->request); nvme_tcp_done_send_req(queue); } From patchwork Tue Jan 28 16:34:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13952772 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6A681DE4C8; Tue, 28 Jan 2025 16:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082112; cv=none; b=BcV8nYI/KfpO/MUDDsnOOdu+RiaNs6FcLlnEC9uDL0Hd0PyP8MEXPH3TehJpgx+P101SFnBzMG7iAw+w1B4iKBQPohPICY4eDOR2delft9/uPUAQmnyHV3MYe8bYKvBbPZaKi3gmvyBfT4mo3BY4sdM4t6/mpW3AU5bmwMhSBjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082112; c=relaxed/simple; bh=BYg80m4FjS4dU3qsCOeFHzQpyGsVbs++H0+ZTCLs+A8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LQYTBquzdZu3LmXMz5T+LQ3WWvhqmw63x7f/zQZgGVHUy5rXSso/dX1spn1Yf5bZbRf8A5WmhR+QWNgrHRWmN2JEuoj/zuwGNhHzjVvDt8+tOPikZTpbSm1QQIuh450N1ckREyqvhnyKKxg3yvXhUL/BUkV2ocqhn51N4zrPxCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YZVm6473; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YZVm6473" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E22C4CED3; Tue, 28 Jan 2025 16:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738082112; bh=BYg80m4FjS4dU3qsCOeFHzQpyGsVbs++H0+ZTCLs+A8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YZVm6473C6+7opfNH14rx5dnUkBlj4zhaAjUpsEQNDNTCnLLu/Rzfzta8vrarHLqN ZhGz827rekIWDNSPJqNcymJJTpVgANY8F7FXelNfiwuTGbuhooeCZf2GU3vPabISq3 J41ena74J/NVAvzzX+1ON8SQxvNNTuGNwZtbm3qTDG8IYEkjvZsFviB/FyxPAIhMkC IHsztiFrrgcIL8rTVupJJutOZk7BOPcyHLRMy8OOFYIIwit6Be6gF6tw6kygbAET6o oFLpQGww4yPZjTvx/oEyw9IrCmZhRP6emPlBSyNeS2AoydB9O5kjIpKagY+xc1Kqge ZmjbkJYkNDsqQ== From: Daniel Wagner Date: Tue, 28 Jan 2025 17:34:47 +0100 Subject: [PATCH 2/3] nvme-fc: use ctrl state getter Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250128-nvme-misc-fixes-v1-2-40c586581171@kernel.org> References: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> In-Reply-To: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Ming Lei Cc: James Smart , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.2 Do not access the state variable directly, instead use proper synchronization so not stale data is read. Fixes: e6e7f7ac03e4 ("nvme: ensure reset state check ordering") Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/host/fc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 55884d3df6f291cfddb4742e135b54a72f1cfa05..f4f1866fbd5b8b05730a785c7d256108c9344e62 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2087,7 +2087,8 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) nvme_fc_complete_rq(rq); check_error: - if (terminate_assoc && ctrl->ctrl.state != NVME_CTRL_RESETTING) + if (terminate_assoc && + nvme_ctrl_state(&ctrl->ctrl) != NVME_CTRL_RESETTING) queue_work(nvme_reset_wq, &ctrl->ioerr_work); } @@ -2541,6 +2542,8 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues) static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) { + enum nvme_ctrl_state state = nvme_ctrl_state(&ctrl->ctrl); + /* * if an error (io timeout, etc) while (re)connecting, the remote * port requested terminating of the association (disconnect_ls) @@ -2548,7 +2551,7 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) * the controller. Abort any ios on the association and let the * create_association error path resolve things. */ - if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { + if (state == NVME_CTRL_CONNECTING) { __nvme_fc_abort_outstanding_ios(ctrl, true); dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: transport error during (re)connect\n", @@ -2557,7 +2560,7 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) } /* Otherwise, only proceed if in LIVE state - e.g. on first error */ - if (ctrl->ctrl.state != NVME_CTRL_LIVE) + if (state != NVME_CTRL_LIVE) return; dev_warn(ctrl->ctrl.device, From patchwork Tue Jan 28 16:34:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13952773 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C595D1DE4F3; Tue, 28 Jan 2025 16:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082114; cv=none; b=h9hNcVrvVTbwHTsoqq+/gDnuyyg8QzkxXisn9SX4kAr/M569fimmfUJYm6iwG9hG87OJIZyDQCkHg/UDKujLgnzNTWjDZDrJnHkPE5ydLTDUaodmFPpL3AyJEHTpz1fitATzjMC5IUOr9wJFjoY1JfCNy8Ztxo5I0RScoU1bG5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738082114; c=relaxed/simple; bh=IzcjVmVuBIS5G+lZmSs0a5GGbYPjcP4YaCwLUAG7tcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nFSrRAFKHAJbiFdOr/Op2XLhDrtsSoDrmgCtkfk7Ajr+87tLLKqn+i3hoNiTp44yUYXhFWsycWwZ+TAk2l3Or3x4tGyGks0gGHTNNxkifa/czR0hTN/AW3mz7uF7yPM/GUBK5bzrcoE1yLtlo7GwkrnVStQLwRMNPZ+aCa8AhNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GD1PYUpH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GD1PYUpH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C93C4CEF1; Tue, 28 Jan 2025 16:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738082114; bh=IzcjVmVuBIS5G+lZmSs0a5GGbYPjcP4YaCwLUAG7tcs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GD1PYUpHYnlAZu3zZ/6p+BZILmWYaepfLpRpIKfx8nX8dptXveZR7XoMs+ecIjCos qKO4pt7udVedW1+j+yzidTTMfU4XB/i62ghejeHSp47cV723LHSSXUfkVyHGDc0ul3 uqCuk/KRuM5EX2P9Ss/jBQwkcfXrJ6/RZb9iCdrLPd/J3Gljfz74if4mquWKebijwd lJWr9ayvSDuU+MO4CRgs3uZ/sK2yH2DJPIfYbvNd+Qi+SyRJeG7xyfm3+PSWJyK3Ac YyxcaDwtR/QKUWUYhkY+ODss1J8BR3y5ShcUYEDQdmIiXeW+qQs0vkWv/lYxAgpZS0 Kk37shHCBcr+Q== From: Daniel Wagner Date: Tue, 28 Jan 2025 17:34:48 +0100 Subject: [PATCH 3/3] blk-mq: fix wait condition for tagset wait completed check Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250128-nvme-misc-fixes-v1-3-40c586581171@kernel.org> References: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> In-Reply-To: <20250128-nvme-misc-fixes-v1-0-40c586581171@kernel.org> To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Ming Lei Cc: James Smart , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.2 blk_mq_tagset_count_completed_reqs returns the number of completed requests. The only user of this function is blk_mq_tagset_wait_completed_request which wants to know how many request are not yet completed. Thus return the number of in flight requests and terminate the wait loop when there is no inflight request. Fixes: f9934a80f91d ("blk-mq: introduce blk_mq_tagset_wait_completed_request()") Cc: Ming Lei Signed-off-by: Daniel Wagner --- block/blk-mq-tag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index b9f417d980b46d54b74dec8adcb5b04e6a78635c..3ce46afb65e3c3de9f11ca440bf0f335f21d0998 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -450,11 +450,11 @@ void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, } EXPORT_SYMBOL(blk_mq_tagset_busy_iter); -static bool blk_mq_tagset_count_completed_rqs(struct request *rq, void *data) +static bool blk_mq_tagset_count_inflight_rqs(struct request *rq, void *data) { unsigned *count = data; - if (blk_mq_request_completed(rq)) + if (blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) (*count)++; return true; } @@ -472,7 +472,7 @@ void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset) unsigned count = 0; blk_mq_tagset_busy_iter(tagset, - blk_mq_tagset_count_completed_rqs, &count); + blk_mq_tagset_count_inflight_rqs, &count); if (!count) break; msleep(5);