summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-12 10:15:42 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-12 10:15:42 -0600
commit17318cf6e42ef6b8d14e400eb1f6cc78dd668e1d (patch)
treea999438064e16fa063a567b99b2affc43202d69e
parentad46c5715ffc5d4e70d2e941225b1f504f23e409 (diff)
downloadfio-17318cf6e42ef6b8d14e400eb1f6cc78dd668e1d.tar.gz
fio-17318cf6e42ef6b8d14e400eb1f6cc78dd668e1d.tar.bz2
engines/io_uring: fix crash with registerfiles=1
If used with a raw bdev, we're crashing in attempting to open a registered file before we have actually registered them. If we're called before files are registered, just open the file normally. This is done to query sizes etc, and we'll get the file closed after that anyway. The job open/close will use the right registered fd. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--engines/io_uring.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/io_uring.c b/engines/io_uring.c
index 10cfe9f2..65f8e236 100644
--- a/engines/io_uring.c
+++ b/engines/io_uring.c
@@ -555,6 +555,7 @@ static int fio_ioring_post_init(struct thread_data *td)
return 1;
}
+ printf("files=%d\n", o->registerfiles);
if (o->registerfiles) {
err = fio_ioring_register_files(td);
if (err) {
@@ -613,7 +614,7 @@ static int fio_ioring_open_file(struct thread_data *td, struct fio_file *f)
struct ioring_data *ld = td->io_ops_data;
struct ioring_options *o = td->eo;
- if (!o->registerfiles)
+ if (!ld || !o->registerfiles)
return generic_open_file(td, f);
f->fd = ld->fds[f->engine_pos];
@@ -622,9 +623,10 @@ static int fio_ioring_open_file(struct thread_data *td, struct fio_file *f)
static int fio_ioring_close_file(struct thread_data *td, struct fio_file *f)
{
+ struct ioring_data *ld = td->io_ops_data;
struct ioring_options *o = td->eo;
- if (!o->registerfiles)
+ if (!ld || !o->registerfiles)
return generic_close_file(td, f);
f->fd = -1;