[RFC PATCH 2/5] block: ioprio hint to low-level device drivers
From: Jason B. Akers
Date: Wed Oct 29 2014 - 14:36:45 EST
From: Dan Williams <dan.j.williams@xxxxxxxxx>
The priority in the io_context is consumed by the io scheduler. For
caching advice we need the request->ioprio field to be up-to-date. Set
the bio ioprio at submit time.
Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
Signed-off-by: Jason B. Akers <jason.b.akers@xxxxxxxxx>
---
block/bio.c | 1 +
block/ioprio.c | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 3e6e198..e133b5c 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2009,6 +2009,7 @@ int bio_associate_current(struct bio *bio)
/* acquire active ref on @ioc and associate */
get_io_context_active(ioc);
bio->bi_ioc = ioc;
+ bio_set_prio(bio, ioprio_best(ioc->ioprio, bio_prio(bio)));
/* associate blkcg if exists */
rcu_read_lock();
diff --git a/block/ioprio.c b/block/ioprio.c
index e50170c..fec1202 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -159,18 +159,28 @@ int ioprio_best(unsigned short aprio, unsigned short bprio)
{
unsigned short aclass = IOPRIO_PRIO_CLASS(aprio);
unsigned short bclass = IOPRIO_PRIO_CLASS(bprio);
+ unsigned short class, data, advice;
if (aclass == IOPRIO_CLASS_NONE)
aclass = IOPRIO_CLASS_BE;
if (bclass == IOPRIO_CLASS_NONE)
bclass = IOPRIO_CLASS_BE;
- if (aclass == bclass)
- return min(aprio, bprio);
- if (aclass > bclass)
- return bprio;
- else
- return aprio;
+ /* best priority */
+ if (aclass == bclass) {
+ class = aclass;
+ data = min(IOPRIO_PRIO_DATA(aprio), IOPRIO_PRIO_DATA(bprio));
+ } else if (aclass > bclass) {
+ class = bclass;
+ data = IOPRIO_PRIO_DATA(bprio);
+ } else {
+ class = aclass;
+ data = IOPRIO_PRIO_DATA(aprio);
+ }
+
+ /* best cache advice, assumes invalid advice is zero */
+ advice = max(IOPRIO_ADVICE(aprio), IOPRIO_ADVICE(bprio));
+ return IOPRIO_ADVISE(class, data, advice);
}
SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/