History

scsi: block: ioprio: Clean up interface definition

The I/O priority user interface defines the 16-bits ioprio values as the combination of the upper 3-bits for an I/O priority class and the lower 13-bits as priority data. However, the kernel only uses the lower 3-bits of the priority data to define priority levels for the RT and BE priority classes. The data part of an ioprio value is completely ignored for the IDLE and NONE classes. This is enforced by checks done in ioprio_check_cap(), which is called for all paths that allow defining an I/O priority for I/Os: the per-context ioprio_set() system call, aio interface and io_uring interface. Clarify this fact in the uapi ioprio.h header file and introduce the IOPRIO_PRIO_LEVEL_MASK and IOPRIO_PRIO_LEVEL() macros for users to define and get priority levels in an ioprio value. The coarser macro IOPRIO_PRIO_DATA() is retained for backward compatibility with old applications already using it. There is no functional change introduced with this. In-kernel users of the IOPRIO_PRIO_DATA() macro which are explicitly handling I/O priority data as a priority level are modified to use the new IOPRIO_PRIO_LEVEL() macro without any functional change. Since f2fs is the only user of this macro not explicitly using that value as a priority level, it is left unchanged.

Damien Le Moal committed 3 years ago

Commit eca20401 parent ac9a7863 files · +21 −12Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/ioprio.h+14−5
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 ((data) & IOPRIO_PRIO_MASK))
1818
1919 /*
20− * These are the io priority groups as implemented by the BFQ and mq-deadline
20+ * These are the io priority classes as implemented by the BFQ and mq-deadline
2121 * schedulers. RT is the realtime class, it always gets premium service. For
2222 * ATA disks supporting NCQ IO priority, RT class IOs will be processed using
2323 * high priority NCQ commands. BE is the best-effort scheduling class, the
@@ -32,11 +32,20 @@ enum { · 8 unmodified lines
3232 };
3333
3434 /*
35− * The RT and BE priority classes both support up to 8 priority levels.
35+ * The RT and BE priority classes both support up to 8 priority levels that
36+ * can be specified using the lower 3-bits of the priority data.
3637 */
37−#define IOPRIO_NR_LEVELS 8
38−#define IOPRIO_BE_NR IOPRIO_NR_LEVELS
38+#define IOPRIO_LEVEL_NR_BITS 3
39+#define IOPRIO_NR_LEVELS (1 << IOPRIO_LEVEL_NR_BITS)
40+#define IOPRIO_LEVEL_MASK (IOPRIO_NR_LEVELS - 1)
41+#define IOPRIO_PRIO_LEVEL(ioprio) ((ioprio) & IOPRIO_LEVEL_MASK)
3942
43+#define IOPRIO_BE_NR IOPRIO_NR_LEVELS
44+
45+/*
46+ * Possible values for the "which" argument of the ioprio_get() and
47+ * ioprio_set() system calls (see "man ioprio_set").
48+ */
4049 enum {
4150 IOPRIO_WHO_PROCESS = 1,
4251 IOPRIO_WHO_PGRP,
@@ -44,7 +53,7 @@ enum { · 1 unmodified line
4453 };
4554
4655 /*
47− * Fallback BE priority level.
56+ * Fallback BE class priority level.
4857 */
4958 #define IOPRIO_NORM 4
5059 #define IOPRIO_BE_NORM IOPRIO_NORM

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t