Skip to content

Commit

Permalink
fio: add FIO_RO_NEEDS_RW_OPEN ioengine flag
Browse files Browse the repository at this point in the history
Some oddball cases like sg/bsg require devices to be opened for writing
in order to do read commands. So fio has been opening character devices
in rw mode for read workloads. However, nvme generic character devices
do not need (and may refuse) a writeable open for read workloads. So
instead of always opening character devices in rw mode, open devices in
rw mode for read workloads only if the ioengine has the
FIO_RO_NEEDS_RW_OPEN flag.

Link: https://lore.kernel.org/fio/[email protected]/
Signed-off-by: Vincent Fu <[email protected]>
  • Loading branch information
vincentkfu committed Feb 3, 2023
1 parent 3a6ae7b commit d72b10e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion engines/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ static struct ioengine_ops ioengine = {
.open_file = fio_sgio_open,
.close_file = fio_sgio_close,
.get_file_size = fio_sgio_get_file_size,
.flags = FIO_SYNCIO | FIO_RAWIO,
.flags = FIO_SYNCIO | FIO_RAWIO | FIO_RO_NEEDS_RW_OPEN,
.options = options,
.option_struct_size = sizeof(struct sg_options)
};
Expand Down
2 changes: 1 addition & 1 deletion filesetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
else
from_hash = file_lookup_open(f, flags);
} else if (td_read(td)) {
if (f->filetype == FIO_TYPE_CHAR && !read_only)
if (td_ioengine_flagged(td, FIO_RO_NEEDS_RW_OPEN) && !read_only)
flags |= O_RDWR;
else
flags |= O_RDONLY;
Expand Down
2 changes: 2 additions & 0 deletions ioengines.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ enum fio_ioengine_flags {
= 1 << 16, /* async ioengine with commit function that sets issue_time */
FIO_SKIPPABLE_IOMEM_ALLOC
= 1 << 17, /* skip iomem_alloc & iomem_free if job sets mem/iomem */
FIO_RO_NEEDS_RW_OPEN
= 1 << 18, /* open files in rw mode even if we have a read job */
};

/*
Expand Down

0 comments on commit d72b10e

Please sign in to comment.