From 6cefbe338b159edc9417da5840383765acbd92c7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Apr 2007 12:46:56 +0200 Subject: [PATCH] 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 --- options.c | 14 ++++++++++++++ os/os-linux.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/options.c b/options.c index 7a81880a..230c47dd 100644 --- 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 diff --git a/os/os-linux.h b/os/os-linux.h index 90349016..a4f7b244 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -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 -- 2.25.1