From: Jens Axboe Date: Fri, 15 Dec 2017 16:08:26 +0000 (-0700) Subject: ioengines: improve "is this the same IO engine" check X-Git-Tag: fio-3.3~5 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3e262e2fc8e73bae1340aef23a78195b5de82387 ioengines: improve "is this the same IO engine" check We can't just compare the name, that assumes that name and filename match for an IO engine. While that's generally the case for the engines that fio ships with, it's not a requirement, and it's definitely not true for external engines. Fixup the check by re-loading the engine and checking the OPS instead. That should be bullet proof. Fixes: 800334d ("Correctly detect whether ioengine_load can exit early") Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index b9da7133..03cdf902 100644 --- a/init.c +++ b/init.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "fio.h" #ifndef FIO_NO_HAVE_SHM_H @@ -1064,6 +1065,9 @@ int ioengine_load(struct thread_data *td) } if (td->io_ops) { + struct ioengine_ops *ops; + void *dlhandle; + /* An engine is loaded, but the requested ioengine * may have changed. */ @@ -1072,6 +1076,19 @@ int ioengine_load(struct thread_data *td) return 0; } + /* + * Name of file and engine may be different, load ops + * for this name and see if they match. If they do, then + * the engine is unchanged. + */ + dlhandle = td->io_ops_dlhandle; + ops = load_ioengine(td); + if (ops == td->io_ops && dlhandle == td->io_ops_dlhandle) + return 0; + + if (dlhandle && dlhandle != td->io_ops_dlhandle) + dlclose(dlhandle); + /* Unload the old engine. */ free_ioengine(td); }