engines/io_uring_cmd: allocate enough ranges for async trims
[fio.git] / engines / io_uring.c
index 7ac7c755b2813c179efbee0202d771def5ba6ea4..38c36fdca26063fcbb8aacbda7a9b1ec71fb655b 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
 
@@ -1165,10 +1166,13 @@ static int fio_ioring_init(struct thread_data *td)
                        md_size += td->o.mem_align - page_size;
                if (td->o.mem_type == MEM_MALLOC) {
                        ld->md_buf = malloc(md_size);
-                       if (!ld->md_buf)
+                       if (!ld->md_buf) {
+                               free(ld);
                                return 1;
+                       }
                } else {
                        log_err("fio: Only iomem=malloc or mem=malloc is supported\n");
+                       free(ld);
                        return 1;
                }
        }
@@ -1192,7 +1196,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;
 }
@@ -1296,6 +1300,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);