zbd: remove zbd_zoned_model ZBD_IGNORE
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index 5d9e331ac9347f8e2af3441f4e3a519550b95602..aab4d741365b952743422a9c1b16fad6716f6aab 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -32,6 +32,17 @@ int zbd_get_zoned_model(struct thread_data *td, struct fio_file *f,
 {
        int ret;
 
+       if (f->filetype == FIO_TYPE_PIPE) {
+               log_err("zonemode=zbd does not support pipes\n");
+               return -EINVAL;
+       }
+
+       /* If regular file, always emulate zones inside the file. */
+       if (f->filetype == FIO_TYPE_FILE) {
+               *model = ZBD_NONE;
+               return 0;
+       }
+
        if (td->io_ops && td->io_ops->get_zoned_model)
                ret = td->io_ops->get_zoned_model(td, f, model);
        else
@@ -409,7 +420,7 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)
        int i;
 
        if (zone_size == 0) {
-               log_err("%s: Specifying the zone size is mandatory for regular block devices with --zonemode=zbd\n\n",
+               log_err("%s: Specifying the zone size is mandatory for regular file/block device with --zonemode=zbd\n\n",
                        f->file_name);
                return 1;
        }
@@ -430,6 +441,12 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
+       if (f->real_file_size < zone_size) {
+               log_err("%s: file/device size %"PRIu64" is smaller than zone size %"PRIu64"\n",
+                       f->file_name, f->real_file_size, zone_size);
+               return -EINVAL;
+       }
+
        nr_zones = (f->real_file_size + zone_size - 1) / zone_size;
        zbd_info = scalloc(1, sizeof(*zbd_info) +
                           (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
@@ -644,8 +661,6 @@ static int zbd_create_zone_info(struct thread_data *td, struct fio_file *f)
                return ret;
 
        switch (zbd_model) {
-       case ZBD_IGNORE:
-               return 0;
        case ZBD_HOST_AWARE:
        case ZBD_HOST_MANAGED:
                ret = parse_zone_info(td, f);
@@ -663,6 +678,7 @@ static int zbd_create_zone_info(struct thread_data *td, struct fio_file *f)
                return -EINVAL;
        }
 
+       assert(f->zbd_info);
        f->zbd_info->model = zbd_model;
 
        ret = zbd_set_max_open_zones(td, f);