engines/io_uring_cmd: skip pi verify checks for error cases
[fio.git] / engines / io_uring.c
index 6cdf1b4fe4a12342f198b021cd9f6e3740c5aab4..c0cb5a78f7bdaac645d23dada975b271c363b7ec 100644 (file)
@@ -18,6 +18,7 @@
 #include "../lib/memalign.h"
 #include "../lib/fls.h"
 #include "../lib/roundup.h"
+#include "../verify.h"
 
 #ifdef ARCH_HAVE_IOURING
 
@@ -467,10 +468,12 @@ static struct io_u *fio_ioring_cmd_event(struct thread_data *td, int event)
        cqe = &ld->cq_ring.cqes[index];
        io_u = (struct io_u *) (uintptr_t) cqe->user_data;
 
-       if (cqe->res != 0)
+       if (cqe->res != 0) {
                io_u->error = -cqe->res;
-       else
+               return io_u;
+       } else {
                io_u->error = 0;
+       }
 
        if (o->cmd_type == FIO_URING_CMD_NVME) {
                data = FILE_ENG_DATA(io_u->file);
@@ -1195,7 +1198,7 @@ static int fio_ioring_init(struct thread_data *td)
            td->o.zone_mode == ZONE_MODE_ZBD)
                td->io_ops->flags |= FIO_ASYNCIO_SYNC_TRIM;
        else
-               ld->dsm = calloc(ld->iodepth, sizeof(*ld->dsm));
+               ld->dsm = calloc(td->o.iodepth, sizeof(*ld->dsm));
 
        return 0;
 }
@@ -1278,14 +1281,21 @@ static int fio_ioring_cmd_open_file(struct thread_data *td, struct fio_file *f)
                lba_size = data->lba_ext ? data->lba_ext : data->lba_size;
 
                for_each_rw_ddir(ddir) {
-                       if (td->o.min_bs[ddir] % lba_size ||
-                               td->o.max_bs[ddir] % lba_size) {
-                               if (data->lba_ext)
-                                       log_err("%s: block size must be a multiple of (LBA data size + Metadata size)\n",
-                                               f->file_name);
-                               else
+                       if (td->o.min_bs[ddir] % lba_size || td->o.max_bs[ddir] % lba_size) {
+                               if (data->lba_ext) {
+                                       log_err("%s: block size must be a multiple of %u "
+                                               "(LBA data size + Metadata size)\n", f->file_name, lba_size);
+                                       if (td->o.min_bs[ddir] == td->o.max_bs[ddir] &&
+                                           !(td->o.min_bs[ddir] % data->lba_size)) {
+                                               /* fixed block size is actually a multiple of LBA data size */
+                                               unsigned long long suggestion = lba_size *
+                                                       (td->o.min_bs[ddir] / data->lba_size);
+                                               log_err("Did you mean to use a block size of %llu?\n", suggestion);
+                                       }
+                               } else {
                                        log_err("%s: block size must be a multiple of LBA data size\n",
                                                f->file_name);
+                               }
                                td_verror(td, EINVAL, "fio_ioring_cmd_open_file");
                                return 1;
                        }
@@ -1299,6 +1309,19 @@ static int fio_ioring_cmd_open_file(struct thread_data *td, struct fio_file *f)
                                return 1;
                        }
                 }
+
+               /*
+                * For extended logical block sizes we cannot use verify when
+                * end to end data protection checks are enabled, as the PI
+                * section of data buffer conflicts with verify.
+                */
+               if (data->ms && data->pi_type && data->lba_ext &&
+                   td->o.verify != VERIFY_NONE) {
+                       log_err("%s: for extended LBA, verify cannot be used when E2E data protection is enabled\n",
+                               f->file_name);
+                       td_verror(td, EINVAL, "fio_ioring_cmd_open_file");
+                       return 1;
+               }
        }
        if (!ld || !o->registerfiles)
                return generic_open_file(td, f);