Mask in BE ioprio class as default
authorJens Axboe <jens.axboe@oracle.com>
Wed, 18 Apr 2007 10:46:56 +0000 (12:46 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 18 Apr 2007 10:46:56 +0000 (12:46 +0200)
We can't just set the ioprio value, we always have to set a class
as well. If no class is given, just assume it's the default best
effort class we want.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
options.c
os/os-linux.h

index 7a81880a200e03f3e10c3637045a94aa3bcafb37..230c47dd22b48171277bc62392f98267c930a501 100644 (file)
--- a/options.c
+++ b/options.c
@@ -64,6 +64,13 @@ static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
 static int str_prioclass_cb(void *data, unsigned int *val)
 {
        struct thread_data *td = data;
+       unsigned short mask;
+
+       /*
+        * mask off old class bits, str_prio_cb() may have set a default class
+        */
+       mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
+       td->ioprio &= mask;
 
        td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
        return 0;
@@ -74,6 +81,13 @@ static int str_prio_cb(void *data, unsigned int *val)
        struct thread_data *td = data;
 
        td->ioprio |= *val;
+
+       /*
+        * If no class is set, assume BE
+        */
+       if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
+               td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
+
        return 0;
 }
 #endif
index 90349016ffe1004ae84904ec45922125f8e96b4a..a4f7b244172d2dbefc0b24ac754df9327640cc4a 100644 (file)
@@ -109,12 +109,20 @@ static inline long umem_add(unsigned long *uptr, unsigned long inc)
 }
 #endif /* FIO_HAVE_SYSLET */
 
+enum {
+       IOPRIO_CLASS_NONE,
+       IOPRIO_CLASS_RT,
+       IOPRIO_CLASS_BE,
+       IOPRIO_CLASS_IDLE,
+};
+
 enum {
        IOPRIO_WHO_PROCESS = 1,
        IOPRIO_WHO_PGRP,
        IOPRIO_WHO_USER,
 };
 
+#define IOPRIO_BITS            16
 #define IOPRIO_CLASS_SHIFT     13
 
 #ifndef BLKGETSIZE64