]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
block: Optimize ioprio_best()
authorBart Van Assche <bart.vanassche@sandisk.com>
Wed, 19 Apr 2017 21:01:28 +0000 (14:01 -0700)
committerJens Axboe <axboe@fb.com>
Wed, 19 Apr 2017 23:38:36 +0000 (17:38 -0600)
Since ioprio_best() translates IOPRIO_CLASS_NONE into IOPRIO_CLASS_BE
and since lower numerical priority values represent a higher priority
a simple numerical comparison is sufficient.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
Tested-by: Adam Manzanares <adam.manzanares@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/ioprio.c

index 0c47a00f92a852542dc11be132a30d44e9af055c..4b120c9cf7e8b1bd5ce45a55371454d9785f0c37 100644 (file)
@@ -163,22 +163,12 @@ out:
 
 int ioprio_best(unsigned short aprio, unsigned short bprio)
 {
-       unsigned short aclass;
-       unsigned short bclass;
-
        if (!ioprio_valid(aprio))
                aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
        if (!ioprio_valid(bprio))
                bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
 
-       aclass = IOPRIO_PRIO_CLASS(aprio);
-       bclass = IOPRIO_PRIO_CLASS(bprio);
-       if (aclass == bclass)
-               return min(aprio, bprio);
-       if (aclass > bclass)
-               return bprio;
-       else
-               return aprio;
+       return min(aprio, bprio);
 }
 
 SYSCALL_DEFINE2(ioprio_get, int, which, int, who)