]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvme: fix misaccounting of nvme-mpath inflight I/O
authorYu Kuai <yukuai3@huawei.com>
Tue, 15 Jul 2025 01:28:12 +0000 (09:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:51:52 +0000 (08:51 +0200)
commitda1a85e32e0716fff608c69b4ccefcdfe16e432c
treeb83243fd5835b7907ff7f7d586fa0bab3d89331e
parent0a4eec84d4d2c4085d4ed8630fd74e4b39033c1b
nvme: fix misaccounting of nvme-mpath inflight I/O

[ Upstream commit 71257925e83eae1cb6913d65ca71927d2220e6d1 ]

Procedures for nvme-mpath IO accounting:

 1) initialize nvme_request and clear flags;
 2) set NVME_MPATH_IO_STATS and increase inflight counter when IO
    started;
 3) check NVME_MPATH_IO_STATS and decrease inflight counter when IO is
    done;

However, for the case nvme_fail_nonready_command(), both step 1) and 2)
are skipped, and if old nvme_request set NVME_MPATH_IO_STATS and then
request is reused, step 3) will still be executed, causing inflight I/O
counter to be negative.

Fix the problem by clearing nvme_request in nvme_fail_nonready_command().

Fixes: ea5e5f42cd2c ("nvme-fabrics: avoid double completions in nvmf_fail_nonready_command")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/all/CAHj4cs_+dauobyYyP805t33WMJVzOWj=7+51p4_j9rA63D9sog@mail.gmail.com/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/core.c