Mask in BE ioprio class as default
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>
diff --git a/options.c b/options.c
index 7a81880..230c47d 100644
--- a/options.c
+++ b/options.c
@@ -64,6 +64,13 @@
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 @@
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