From ff0047816d74951247567607f7d8977fe780f7a2 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 7 Feb 2017 14:16:05 -0700 Subject: [PATCH] nvme: track submit time instead of timeout time This removes one addition from the submission path (negligible, but a nice side effect), but also opens up the possibility of reporting the total time an I/O took - since we are always tracking the submission time anyway, there is no extra cost to report it in the completion callback. Change-Id: I7129e7c09d20da8082042a7622d045846461dd9c Signed-off-by: Daniel Verkamp --- lib/nvme/nvme_pcie.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index a21380513..36f87be02 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -124,7 +124,9 @@ struct nvme_tracker { uint32_t rsvd2; - uint64_t timeout_tick; + /* The value of spdk_get_ticks() when the tracker was submitted to the hardware. */ + uint64_t submit_tick; + uint64_t prp_sgl_bus_addr; union { @@ -1011,7 +1013,7 @@ nvme_pcie_qpair_submit_tracker(struct spdk_nvme_qpair *qpair, struct nvme_tracke struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair); struct nvme_pcie_ctrlr *pctrlr = nvme_pcie_ctrlr(qpair->ctrlr); - tr->timeout_tick = spdk_get_ticks() + qpair->ctrlr->timeout_ticks; + tr->submit_tick = spdk_get_ticks(); req = tr->req; pqpair->tr[tr->cid].active = true; @@ -1834,7 +1836,7 @@ nvme_pcie_qpair_check_timeout(struct spdk_nvme_qpair *qpair) } t02 = spdk_get_ticks(); - if (tr->timeout_tick <= t02) { + if (tr->submit_tick + ctrlr->timeout_ticks <= t02) { /* * Request has timed out. This could be i/o or admin request. * Call the registered timeout function for user to take action.