zbd: avoid assertions during sequential read I/O
authorDmitry Fomichev <dmitry.fomichev@wdc.com>
Tue, 6 Feb 2024 10:57:51 +0000 (19:57 +0900)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 7 Feb 2024 13:43:13 +0000 (08:43 -0500)
The following assert has been observed to be triggered
if the I/O offset + I/O size exceeds the device capacity in a
sequential read workload -

“zbd.c:110: zone_lock: Assertion `f->min_zone <= nz && nz < f->max_zone' failed.”

The code in zbd_zone_align_file_sizes() rounds down the I/O size to
avoid these situations, but it is bypassed if
td->o.td_ddir == TD_DDIR_READ.

Avoid this issue by modifying zbd_zone_align_file_sizes() to round down
the I/O size for read I/Os and leave the I/O offset untouched.

Fixes: bfbdd35b3e8f ("Add support for zoned block devices")
Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20240206105755.214891-2-dmitry.fomichev@wdc.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
zbd.c

diff --git a/zbd.c b/zbd.c
index 61b5b688ca9aba5df7f9103590da914be6786d03..7577472e9f8f035d8a9fe2709b2244aa72238b8e 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -674,9 +674,20 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td,
                return false;
        }
 
+       if (td->o.td_ddir == TD_DDIR_READ) {
+               z = zbd_offset_to_zone(f, f->file_offset + f->io_size);
+               new_end = z->start;
+               if (f->file_offset + f->io_size > new_end) {
+                       log_info("%s: rounded io_size from %"PRIu64" to %"PRIu64"\n",
+                                f->file_name, f->io_size,
+                                new_end - f->file_offset);
+                       f->io_size = new_end - f->file_offset;
+               }
+               return true;
+       }
+
        z = zbd_offset_to_zone(f, f->file_offset);
-       if ((f->file_offset != z->start) &&
-           (td->o.td_ddir != TD_DDIR_READ)) {
+       if (f->file_offset != z->start) {
                new_offset = zbd_zone_end(z);
                if (new_offset >= f->file_offset + f->io_size) {
                        log_info("%s: io_size must be at least one zone\n",
@@ -692,8 +703,7 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td,
 
        z = zbd_offset_to_zone(f, f->file_offset + f->io_size);
        new_end = z->start;
-       if ((td->o.td_ddir != TD_DDIR_READ) &&
-           (f->file_offset + f->io_size != new_end)) {
+       if (f->file_offset + f->io_size != new_end) {
                if (new_end <= f->file_offset) {
                        log_info("%s: io_size must be at least one zone\n",
                                 f->file_name);