fio: Open bdevs inside a thread message
This ensures that these operations occur on an SPDK thread Change-Id: I265c814a289bdb8c95421c2675b35bf8c0074cc3 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/436554 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
443c6e401b
commit
5d81ab16d4
@ -73,6 +73,7 @@ struct spdk_fio_thread {
|
||||
uint64_t timeout; /* polling timeout */
|
||||
|
||||
TAILQ_HEAD(, spdk_fio_target) targets;
|
||||
bool failed; /* true if the thread failed to initialize */
|
||||
|
||||
struct io_u **iocq; /* io completion queue */
|
||||
unsigned int iocq_count; /* number of iocq entries filled by last getevents */
|
||||
@ -408,19 +409,15 @@ spdk_fio_setup(struct thread_data *td)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Called for each thread, on that thread, shortly after the thread
|
||||
* starts.
|
||||
*/
|
||||
static int
|
||||
spdk_fio_init(struct thread_data *td)
|
||||
static void
|
||||
spdk_fio_bdev_open(void *arg)
|
||||
{
|
||||
struct thread_data *td = arg;
|
||||
struct spdk_fio_thread *fio_thread;
|
||||
unsigned int i;
|
||||
struct fio_file *f;
|
||||
int rc;
|
||||
|
||||
spdk_fio_init_thread(td);
|
||||
|
||||
fio_thread = td->io_ops_data;
|
||||
|
||||
for_each_file(td, f, i) {
|
||||
@ -429,21 +426,24 @@ spdk_fio_init(struct thread_data *td)
|
||||
target = calloc(1, sizeof(*target));
|
||||
if (!target) {
|
||||
SPDK_ERRLOG("Unable to allocate memory for I/O target.\n");
|
||||
return -1;
|
||||
fio_thread->failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
target->bdev = spdk_bdev_get_by_name(f->file_name);
|
||||
if (!target->bdev) {
|
||||
SPDK_ERRLOG("Unable to find bdev with name %s\n", f->file_name);
|
||||
free(target);
|
||||
return -1;
|
||||
fio_thread->failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
rc = spdk_bdev_open(target->bdev, true, NULL, NULL, &target->desc);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Unable to open bdev %s\n", f->file_name);
|
||||
free(target);
|
||||
return -1;
|
||||
fio_thread->failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
target->ch = spdk_bdev_get_io_channel(target->desc);
|
||||
@ -451,13 +451,36 @@ spdk_fio_init(struct thread_data *td)
|
||||
SPDK_ERRLOG("Unable to get I/O channel for bdev.\n");
|
||||
spdk_bdev_close(target->desc);
|
||||
free(target);
|
||||
return -1;
|
||||
fio_thread->failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
f->engine_data = target;
|
||||
|
||||
TAILQ_INSERT_TAIL(&fio_thread->targets, target, link);
|
||||
}
|
||||
}
|
||||
|
||||
/* Called for each thread, on that thread, shortly after the thread
|
||||
* starts.
|
||||
*/
|
||||
static int
|
||||
spdk_fio_init(struct thread_data *td)
|
||||
{
|
||||
struct spdk_fio_thread *fio_thread;
|
||||
|
||||
spdk_fio_init_thread(td);
|
||||
|
||||
fio_thread = td->io_ops_data;
|
||||
fio_thread->failed = false;
|
||||
|
||||
spdk_thread_send_msg(fio_thread->thread, spdk_fio_bdev_open, td);
|
||||
|
||||
while (spdk_fio_poll_thread(fio_thread) > 0) {}
|
||||
|
||||
if (fio_thread->failed) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user