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 <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1542
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Darek Stojaczyk 2020-03-27 16:03:02 +01:00 committed by Tomasz Zawadzki
parent ba909d9930
commit 410bdfdbe3

View File

@ -433,9 +433,22 @@ spdk_fio_setup(struct thread_data *td)
g_spdk_env_initialized = true; 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) { for_each_file(td, f, i) {
struct spdk_bdev *bdev; struct spdk_bdev *bdev;
if (strcmp(f->file_name, "*") == 0) {
continue;
}
bdev = spdk_bdev_get_by_name(f->file_name); bdev = spdk_bdev_get_by_name(f->file_name);
if (!bdev) { if (!bdev) {
SPDK_ERRLOG("Unable to find bdev with name %s\n", f->file_name); 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) { for_each_file(td, f, i) {
struct spdk_fio_target *target; struct spdk_fio_target *target;
if (strcmp(f->file_name, "*") == 0) {
continue;
}
target = calloc(1, sizeof(*target)); target = calloc(1, sizeof(*target));
if (!target) { if (!target) {
SPDK_ERRLOG("Unable to allocate memory for I/O target.\n"); SPDK_ERRLOG("Unable to allocate memory for I/O target.\n");