Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to F_SET_RW_HINT if F_SET_FILE_RW_HINT is not supported #1682

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions ioengines.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,19 +590,21 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
if (fio_option_is_set(&td->o, write_hint) &&
(f->filetype == FIO_TYPE_BLOCK || f->filetype == FIO_TYPE_FILE)) {
uint64_t hint = td->o.write_hint;
int cmd;
int res;

/*
* For direct IO, we just need/want to set the hint on
* the file descriptor. For buffered IO, we need to set
* it on the inode.
* For direct IO, set the hint on the file descriptor if that is
* supported. Otherwise set it on the inode. For buffered IO, we
* need to set it on the inode.
*/
if (td->o.odirect)
cmd = F_SET_FILE_RW_HINT;
else
cmd = F_SET_RW_HINT;

if (fcntl(f->fd, cmd, &hint) < 0) {
if (td->o.odirect) {
res = fcntl(f->fd, F_SET_FILE_RW_HINT, &hint);
if (res < 0)
res = fcntl(f->fd, F_SET_RW_HINT, &hint);
} else {
res = fcntl(f->fd, F_SET_RW_HINT, &hint);
}
if (res < 0) {
td_verror(td, errno, "fcntl write hint");
goto err;
}
Expand Down