From 3edf255572874da047fa7d41958ff20011bab8d7 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Mon, 7 Jun 2021 11:29:34 +0000 Subject: [PATCH] bdev/fio_plugin: spdk_fio_get_zoned_model() is too permissive The .get_zoned_model() callback is supposed to reject unsupported file types. Right now, we do not reject unsupported file types. For our specific ioengine, this isn't strictly needed, since our ioengine unconditionally sets f->filetype to FIO_TYPE_BLOCK, and if it fails to find a SPDK bdev that matches the --filename, it will return an error that it couldn't find the bdev matching filename. However, all .get_zoned_model() callbacks in the fio in-tree ioengines have a check that a given file has a file type that is supported by the ioengine itself. This is needed since they do not set f->filetype themselves, but instead let fio generic code initialize f->filetype. Since we reuse --filename to mean something in the SPDK namespace, we are force to initialize filetype manually. So that is the only reason why we know that the file type will be FIO_TYPE_BLOCK. Anyway, let's try to keep our code as similar to the in-tree ioengines as possible. The SPDK nvme ioengine already has this check, so adding it in the SPDK bdev ioengine makes our ioengines more consistent as well. Signed-off-by: Niklas Cassel Change-Id: Ib5e19c738dea0f8d41641b63d0fabe055a930827 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8329 Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- examples/bdev/fio_plugin/fio_plugin.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 6ca5b458b..9d047dd1b 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -841,6 +841,11 @@ spdk_fio_get_zoned_model(struct thread_data *td, struct fio_file *f, enum zbd_zo { struct spdk_bdev *bdev; + if (f->filetype != FIO_TYPE_BLOCK) { + SPDK_ERRLOG("Unsupported filetype: %d\n", f->filetype); + return -EINVAL; + } + bdev = spdk_bdev_get_by_name(f->file_name); if (!bdev) { SPDK_ERRLOG("Cannot get zoned model, no bdev with name: %s\n", f->file_name);