X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Flibzbc.c;h=2aacf7bbebecd3ca0d2a5f11a5346ab26c429c86;hb=6a2299789dccdd24351744476586e7d562a3940d;hp=8c682de606db56025de696f3de891bd098f55bf3;hpb=427a7e0950a49a6e350a8e63a31cd8b1f331d4cc;p=fio.git diff --git a/engines/libzbc.c b/engines/libzbc.c index 8c682de6..2aacf7bb 100644 --- a/engines/libzbc.c +++ b/engines/libzbc.c @@ -47,7 +47,7 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f, struct libzbc_data **p_ld) { struct libzbc_data *ld = td->io_ops_data; - int ret, flags = OS_O_DIRECT; + int ret, flags = OS_O_DIRECT; if (ld) { /* Already open */ @@ -61,7 +61,7 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f, return -EINVAL; } - if (td_write(td)) { + if (td_write(td)) { if (!read_only) flags |= O_RDWR; } else if (td_read(td)) { @@ -71,36 +71,32 @@ static int libzbc_open_dev(struct thread_data *td, struct fio_file *f, 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; + log_err("%s: libzbc does not support trim\n", f->file_name); + return -EINVAL; } - if (td->o.oatomic) { + if (td->o.oatomic) { td_verror(td, EINVAL, "libzbc does not support O_ATOMIC"); - log_err("%s: libzbc does not support O_ATOMIC\n", - f->file_name); - return -EINVAL; - } + log_err("%s: libzbc does not support O_ATOMIC\n", f->file_name); + return -EINVAL; + } ld = calloc(1, sizeof(*ld)); if (!ld) return -ENOMEM; ret = zbc_open(f->file_name, - flags | ZBC_O_DRV_SCSI | ZBC_O_DRV_ATA, &ld->zdev); + flags | ZBC_O_DRV_BLOCK | ZBC_O_DRV_SCSI | ZBC_O_DRV_ATA, + &ld->zdev); if (ret) { log_err("%s: zbc_open() failed, err=%d\n", f->file_name, ret); - return ret; + goto err; } ret = libzbc_get_dev_info(ld, f); - if (ret) { - zbc_close(ld->zdev); - free(ld); - return ret; - } + if (ret) + goto err_close; td->io_ops_data = ld; out: @@ -108,6 +104,12 @@ out: *p_ld = ld; return 0; + +err_close: + zbc_close(ld->zdev); +err: + free(ld); + return ret; } static int libzbc_close_dev(struct thread_data *td) @@ -234,6 +236,11 @@ static int libzbc_report_zones(struct thread_data *td, struct fio_file *f, zbdz->start = zones[i].zbz_start << 9; zbdz->len = zones[i].zbz_length << 9; zbdz->wp = zones[i].zbz_write_pointer << 9; + /* + * ZBC/ZAC do not define zone capacity, so use the zone size as + * the zone capacity. + */ + zbdz->capacity = zbdz->len; switch (zones[i].zbz_type) { case ZBC_ZT_CONVENTIONAL: @@ -277,7 +284,7 @@ static int libzbc_report_zones(struct thread_data *td, struct fio_file *f, default: /* Treat all these conditions as offline (don't use!) */ zbdz->cond = ZBD_ZONE_COND_OFFLINE; - break; + zbdz->wp = zbdz->start; } } @@ -396,7 +403,7 @@ static enum fio_q_status libzbc_queue(struct thread_data *td, struct io_u *io_u) return FIO_Q_COMPLETED; } -static struct ioengine_ops ioengine = { +FIO_STATIC struct ioengine_ops ioengine = { .name = "libzbc", .version = FIO_IOOPS_VERSION, .open_file = libzbc_open_file,