From 410bdfdbe3351850c508e67cca150aed538eb7ed Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Fri, 27 Mar 2020 16:03:02 +0100 Subject: [PATCH] bdev/fio_plugin: accept wildcard (*) as fio target FIO in our scripts is usually run as follows: (more or less) fio_bdev /path/to/job.fio --spdk_json_conf=/path/to/spdk.json --filename="$(discover_bdevs /path/to/spdk.json --json)" The bdev names are usually hardcoded in the json config, but still, they have to be provided to fio again. Not anymore - just use --filename=* and FIO will use all available bdevs as I/O targets, just as if all filenames were provided. The above command could be now simplified to: fio_bdev /path/to/job.fio --spdk_json_conf=/path/to/spdk.json --filename=* Change-Id: I56a02e56877b138429d68fb24f1a383c6700c4f4 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1542 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- examples/bdev/fio_plugin/fio_plugin.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index c45ee330d..320f4a6f3 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -433,9 +433,22 @@ spdk_fio_setup(struct thread_data *td) g_spdk_env_initialized = true; } + if (td->o.nr_files == 1 && strcmp(td->files[0]->file_name, "*") == 0) { + struct spdk_bdev *bdev; + + /* add all available bdevs as fio targets */ + for (bdev = spdk_bdev_first_leaf(); bdev; bdev = spdk_bdev_next_leaf(bdev)) { + add_file(td, spdk_bdev_get_name(bdev), 0, 1); + } + } + for_each_file(td, f, i) { struct spdk_bdev *bdev; + if (strcmp(f->file_name, "*") == 0) { + continue; + } + bdev = spdk_bdev_get_by_name(f->file_name); if (!bdev) { SPDK_ERRLOG("Unable to find bdev with name %s\n", f->file_name); @@ -464,6 +477,10 @@ spdk_fio_bdev_open(void *arg) for_each_file(td, f, i) { struct spdk_fio_target *target; + if (strcmp(f->file_name, "*") == 0) { + continue; + } + target = calloc(1, sizeof(*target)); if (!target) { SPDK_ERRLOG("Unable to allocate memory for I/O target.\n");