path: root/zbd.c
diff options
authorDmitry Fomichev <>2021-01-27 13:19:26 +0900
committerJens Axboe <>2021-01-29 08:14:00 -0700
commit0cac10b4a2961630107aa15cbafe8386877ad203 (patch)
treeec002178af13c73326faa93cbef9182ea5e2897f /zbd.c
parent1435114818c399ebe2a8216acbc4c80b3136d676 (diff)
zbd: improve replay range validation
The function zbd_replay_write_order() is called when a read is issued by fio verification code to compare the read data with the previously written data. Any data mismatch is marked as a verification failure. Since zbd_adjust_block() may change the i/o offset and length to comply with i/o constrains that zoned model has set, zbd_replay_write_order() needs to replicate the same adjustment during verify. The general flow in this function matches the write processing done in zbd_adjust_block(), but there are some differences. For example, z->verify_block acts as the pseudo-write pointer during replay and it needs to be advanced by buflen every time the function called, but it is advanced by min_bs in the existing code (the value of this variable is measured in min_bs units). Fix the issue with verify_block and add more error logging to simplify troubleshooting of this tricky part of ZBD code. Signed-off-by: Dmitry Fomichev <> Reviewed-by: Shin'ichiro Kawasaki <> Signed-off-by: Jens Axboe <>
Diffstat (limited to 'zbd.c')
1 files changed, 15 insertions, 2 deletions
diff --git a/zbd.c b/zbd.c
index 44ecb9e0..1ee238e8 100644
--- a/zbd.c
+++ b/zbd.c
@@ -1239,10 +1239,23 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
- if (z->verify_block * min_bs >= z->capacity)
+ if (z->verify_block * min_bs >= z->capacity) {
log_err("%s: %d * %d >= %llu\n", f->file_name, z->verify_block,
min_bs, (unsigned long long)z->capacity);
- io_u->offset = z->start + z->verify_block++ * min_bs;
+ /*
+ * If the assertion below fails during a test run, adding
+ * "--experimental_verify=1" to the command line may help.
+ */
+ assert(false);
+ }
+ io_u->offset = z->start + z->verify_block * min_bs;
+ if (io_u->offset + io_u->buflen >= zbd_zone_capacity_end(z)) {
+ log_err("%s: %llu + %llu >= %lu\n", f->file_name, io_u->offset,
+ io_u->buflen, zbd_zone_capacity_end(z));
+ assert(false);
+ }
+ z->verify_block += io_u->buflen / min_bs;
return z;