aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Fu <vincent.fu@samsung.com>2023-12-11 16:27:21 -0500
committerVincent Fu <vincent.fu@samsung.com>2023-12-11 16:27:21 -0500
commit63e6f55a9147cf9f76376c2e7e38a623c8832f23 (patch)
treeeceafc99ded8e215cac0841789353f811566b8cd
parent3cb50530f4a029992a4b2e2c435481f4007c5cb7 (diff)
parent0cfea592fedf0011e695a604a6961e9cbc1fe9b6 (diff)
downloadfio-63e6f55a9147cf9f76376c2e7e38a623c8832f23.tar.gz
Merge branch 'master' of https://github.com/bvanassche/fio
* 'master' of https://github.com/bvanassche/fio: Fall back to F_SET_RW_HINT if F_SET_FILE_RW_HINT is not supported
-rw-r--r--ioengines.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/ioengines.c b/ioengines.c
index 361727250..87cc2286e 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -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;
}