Commit a553a835 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe
Browse files

block: change ioprio_valid() to an inline function



Change the ioprio_valid() macro in include/usapi/linux/ioprio.h to an
inline function declared on the kernel side in include/linux/ioprio.h.
Also improve checks on the class value by checking the upper bound
value.

Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Link: https://lore.kernel.org/r/20210811033702.368488-4-damien.lemoal@wdc.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 25bca50e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -8,6 +8,16 @@

#include <uapi/linux/ioprio.h>

/*
 * Check that a priority value has a valid class.
 */
static inline bool ioprio_valid(unsigned short ioprio)
{
	unsigned short class = IOPRIO_PRIO_CLASS(ioprio);

	return class > IOPRIO_CLASS_NONE && class <= IOPRIO_CLASS_IDLE;
}

/*
 * if process has set io priority explicitly, use that. if not, convert
 * the cpu scheduler nice value to an io priority
+0 −2
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ enum {
	IOPRIO_CLASS_IDLE,
};

#define ioprio_valid(mask)	(IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)

/*
 * 8 best effort priority levels are supported
 */