Merge branch 'arm-detect-pmull' of https://github.com/sitsofe/fio
[fio.git] / engines / libzbc.c
index 3dde93db54713dbe884a2c6b9d2708ee1af4e01e..abee2043cde60861d6b7ba476d3d18ed11a2408f 100644 (file)
@@ -14,6 +14,7 @@
 #include "fio.h"
 #include "err.h"
 #include "zbd_types.h"
+#include "zbd.h"
 
 struct libzbc_data {
        struct zbc_device       *zdev;
@@ -63,7 +64,7 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f,
                return -EINVAL;
        }
 
-       if (td_write(td)) {
+       if (td_write(td) || td_trim(td)) {
                if (!read_only)
                        flags |= O_RDWR;
        } else if (td_read(td)) {
@@ -71,10 +72,6 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f,
                        flags |= O_RDWR;
                else
                        flags |= O_RDONLY;
-       } else if (td_trim(td)) {
-               td_verror(td, EINVAL, "libzbc does not support trim");
-               log_err("%s: libzbc does not support trim\n", f->file_name);
-               return -EINVAL;
        }
 
        if (td->o.oatomic) {
@@ -180,10 +177,8 @@ static int libzbc_get_zoned_model(struct thread_data *td, struct fio_file *f,
        struct libzbc_data *ld;
        int ret;
 
-       if (f->filetype != FIO_TYPE_BLOCK && f->filetype != FIO_TYPE_CHAR) {
-               *model = ZBD_IGNORE;
-               return 0;
-       }
+       if (f->filetype != FIO_TYPE_BLOCK && f->filetype != FIO_TYPE_CHAR)
+               return -EINVAL;
 
        ret = libzbc_open_dev(td, f, &ld);
        if (ret)
@@ -413,7 +408,11 @@ static enum fio_q_status libzbc_queue(struct thread_data *td, struct io_u *io_u)
                ret = zbc_flush(ld->zdev);
                if (ret)
                        log_err("zbc_flush error %zd\n", ret);
-       } else if (io_u->ddir != DDIR_TRIM) {
+       } else if (io_u->ddir == DDIR_TRIM) {
+               ret = zbd_do_io_u_trim(td, io_u);
+               if (!ret)
+                       ret = EINVAL;
+       } else {
                log_err("Unsupported operation %u\n", io_u->ddir);
                ret = -EINVAL;
        }