I am not quite sure why `latency_ns` is overridden by a fixed value in
qtest mode because personally, I find it much better if I can
individually change requests' latency by modifying the qtest clock.

But I'm not going to change existing behavior for the histogram and
such, so I will just move this override after the latency has been
evaluated regarding a potential BLOCK_IO_DELAY event.

Signed-off-by: Hanna Czenczek <[email protected]>
---
 block/accounting.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/accounting.c b/block/accounting.c
index debf1924455..223becd2e04 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -271,10 +271,6 @@ static void block_account_one_io(BlockAcctStats *stats, 
BlockAcctCookie *cookie,
     int64_t time_ns = qemu_clock_get_ns(clock_type);
     int64_t latency_ns = time_ns - cookie->start_time_ns;
 
-    if (qtest_enabled()) {
-        latency_ns = qtest_latency_ns;
-    }
-
     assert(cookie->type < BLOCK_MAX_IOTYPE);
 
     if (cookie->type == BLOCK_ACCT_NONE) {
@@ -292,6 +288,10 @@ static void block_account_one_io(BlockAcctStats *stats, 
BlockAcctCookie *cookie,
                                        cookie->bytes);
     }
 
+    if (qtest_enabled()) {
+        latency_ns = qtest_latency_ns;
+    }
+
     WITH_QEMU_LOCK_GUARD(&stats->lock) {
         if (failed) {
             stats->failed_ops[cookie->type]++;
-- 
2.55.0


Reply via email to