zbd: fix zone reset condition for verify
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Mon, 14 Nov 2022 02:13:02 +0000 (11:13 +0900)
committerVincent Fu <vincent.fu@samsung.com>
Fri, 18 Nov 2022 14:55:16 +0000 (09:55 -0500)
When data verification is requested, zbd_file_reset() resets zones only
when td->runstate is not TD_VERIFYING so that the data to read back for
verify is not wiped out. However, even when verify data to read is left,
td->runstate is not always TD_VERIFYING. When verify_backlog option is
set, or when block size is not divisor of zone size, zbd_file_reset()
can be called while td->runstate is TD_RUNNING. This causes verify
failures.

To avoid the failures, improve the check condition to reset zones in
zbd_file_reset(). On top of td->runstate, refer td->io_hist_len,
td->verify_batch and td->o.verify_backlog values to avoid zone reset.
This is same check as check_get_verify().

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
zbd.c

diff --git a/zbd.c b/zbd.c
index fadeb45841c81fd0ff41b412cbaaae110c2667ed..97faa0e53bb80c849341e789f06bf9c740a09581 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -1249,6 +1249,7 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f)
 {
        struct fio_zone_info *zb, *ze;
        uint64_t swd;
+       bool verify_data_left = false;
 
        if (!f->zbd_info || !td_write(td))
                return;
@@ -1265,8 +1266,16 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f)
         * writing any data to avoid that a zone reset has to be issued while
         * writing data, which causes data loss.
         */
-       if (td->o.verify != VERIFY_NONE && td->runstate != TD_VERIFYING)
-               zbd_reset_zones(td, f, zb, ze);
+       if (td->o.verify != VERIFY_NONE) {
+               verify_data_left = td->runstate == TD_VERIFYING ||
+                       td->io_hist_len || td->verify_batch;
+               if (td->io_hist_len && td->o.verify_backlog)
+                       verify_data_left =
+                               td->io_hist_len % td->o.verify_backlog;
+               if (!verify_data_left)
+                       zbd_reset_zones(td, f, zb, ze);
+       }
+
        zbd_reset_write_cnt(td, f);
 }