Skip to content

Commit 7f64774

Browse files
nvme: fix misaccounting of nvme-mpath inflight I/O
JIRA: https://issues.redhat.com/browse/RHEL-110941 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: ea5e5f4 ("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> (cherry picked from commit 7125792) Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
1 parent 0b6f585 commit 7f64774

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,10 @@ blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
763763
!test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags) &&
764764
!blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH))
765765
return BLK_STS_RESOURCE;
766+
767+
if (!(rq->rq_flags & RQF_DONTPREP))
768+
nvme_clear_nvme_request(rq);
769+
766770
return nvme_host_path_error(rq);
767771
}
768772
EXPORT_SYMBOL_GPL(nvme_fail_nonready_command);

0 commit comments

Comments
 (0)