Make I/O priority option generic for non-Linux environment [1/2]
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 19 Jul 2016 16:33:43 +0000 (01:33 +0900)
committerJens Axboe <axboe@fb.com>
Tue, 19 Jul 2016 21:45:49 +0000 (15:45 -0600)
There is a kernel that supports I/O priority with a syscall similar
to Linux (e.g. DragonFlyBSD's ioprio_set(2) which apparently seems
to have been inspired by ioprio_set(2) in Linux kernel), however
min/max value of the priority may differ, so use OS specific macros
instead of hardcoded values that are designed to work on Linux.

This commit adds IOPRIO_MIN|MAX_PRIO and IOPRIO_MIN|MAX_PRIO_CLASS
to Linux (incl Android), but no functional changes.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
options.c
os/os-android.h
os/os-linux.h

index 519982394693cb0aa41fe612d08703640b843486..d2a029d14a3204f6906912f1a8dd8de458c3dbe5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -3012,8 +3012,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(ioprio),
                .help   = "Set job IO priority value",
-               .minval = 0,
-               .maxval = 7,
+               .minval = IOPRIO_MIN_PRIO,
+               .maxval = IOPRIO_MAX_PRIO,
                .interval = 1,
                .category = FIO_OPT_C_GENERAL,
                .group  = FIO_OPT_G_CRED,
@@ -3024,8 +3024,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(ioprio_class),
                .help   = "Set job IO priority class",
-               .minval = 0,
-               .maxval = 3,
+               .minval = IOPRIO_MIN_PRIO_CLASS,
+               .maxval = IOPRIO_MAX_PRIO_CLASS,
                .interval = 1,
                .category = FIO_OPT_C_GENERAL,
                .group  = FIO_OPT_G_CRED,
index 1699539cad2a1a525cbec6f98f8ee449f16004af..9e3a3d2af5b4e048dca7cfbecd66141603ddd087 100644 (file)
@@ -140,6 +140,12 @@ enum {
 #define IOPRIO_BITS            16
 #define IOPRIO_CLASS_SHIFT     13
 
+#define IOPRIO_MIN_PRIO                0       /* highest priority */
+#define IOPRIO_MAX_PRIO                7       /* lowest priority */
+
+#define IOPRIO_MIN_PRIO_CLASS  0
+#define IOPRIO_MAX_PRIO_CLASS  3
+
 static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio)
 {
        /*
index b36d33c9804cc60f1c89699c6bd1f41ca4d22e50..a410497c25bf4636a42be935323d536b17bf1c72 100644 (file)
@@ -96,6 +96,12 @@ enum {
 #define IOPRIO_BITS            16
 #define IOPRIO_CLASS_SHIFT     13
 
+#define IOPRIO_MIN_PRIO                0       /* highest priority */
+#define IOPRIO_MAX_PRIO                7       /* lowest priority */
+
+#define IOPRIO_MIN_PRIO_CLASS  0
+#define IOPRIO_MAX_PRIO_CLASS  3
+
 static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio)
 {
        /*