summaryrefslogtreecommitdiff
path: root/engines/libzbc.c
diff options
context:
space:
mode:
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>2021-08-06 10:07:09 +0900
committerJens Axboe <axboe@kernel.dk>2021-08-06 16:39:28 -0600
commit84f07387d900ae9e06ce7b3eadf13273a577b7ca (patch)
tree883a14a99fb16434ec6dc57aaf96f34880baa201 /engines/libzbc.c
parente3be810bf0fdb9f5f50c2871974afb6021cad775 (diff)
downloadfio-84f07387d900ae9e06ce7b3eadf13273a577b7ca.tar.gz
fio-84f07387d900ae9e06ce7b3eadf13273a577b7ca.tar.bz2
engines/libzbc: Enable trim for libzbc I/O engine
The trim workload to zoned block devices is supported as zone reset, and this feature is available for I/O engines which support both zoned devices and trim workload. Libzbc I/O engine supports zoned devices but lacks trim workload support. To enable trim support with libzbc I/O engine, remove the check which inhibited trim from requests to libzbc I/O engine. Also set file open flags for trim same as write, and call zbd_do_io_u_trim() for trim I/O. Of note is that libzbc I/O engine now can support trim to sequential write required zones only. The trim I/Os to conventional zones are reported as an error. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'engines/libzbc.c')
-rw-r--r--engines/libzbc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/engines/libzbc.c b/engines/libzbc.c
index 7f2bc431..abee2043 100644
--- a/engines/libzbc.c
+++ b/engines/libzbc.c
@@ -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) {
@@ -411,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;
}