Commit | Line | Data |
---|---|---|
e9f6567a DLM |
1 | /* |
2 | * IO priority handling declarations and helper functions common to the | |
3 | * libaio and io_uring engines. | |
4 | */ | |
5 | ||
6 | #ifndef FIO_CMDPRIO_H | |
7 | #define FIO_CMDPRIO_H | |
8 | ||
9 | #include "../fio.h" | |
10 | ||
11 | struct cmdprio { | |
12 | unsigned int percentage[DDIR_RWDIR_CNT]; | |
12f9d54a DLM |
13 | unsigned int class[DDIR_RWDIR_CNT]; |
14 | unsigned int level[DDIR_RWDIR_CNT]; | |
e9f6567a DLM |
15 | }; |
16 | ||
17 | static int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio, | |
18 | bool *has_cmdprio) | |
19 | { | |
20 | struct thread_options *to = &td->o; | |
21 | bool has_cmdprio_percentage = false; | |
22 | int i; | |
23 | ||
12f9d54a DLM |
24 | /* |
25 | * If cmdprio_percentage is set and cmdprio_class is not set, | |
26 | * default to RT priority class. | |
27 | */ | |
e9f6567a | 28 | for (i = 0; i < DDIR_RWDIR_CNT; i++) { |
12f9d54a DLM |
29 | if (cmdprio->percentage[i]) { |
30 | if (!cmdprio->class[i]) | |
31 | cmdprio->class[i] = IOPRIO_CLASS_RT; | |
e9f6567a | 32 | has_cmdprio_percentage = true; |
12f9d54a | 33 | } |
e9f6567a DLM |
34 | } |
35 | ||
36 | /* | |
37 | * Check for option conflicts | |
38 | */ | |
39 | if (has_cmdprio_percentage && | |
40 | (fio_option_is_set(to, ioprio) || | |
41 | fio_option_is_set(to, ioprio_class))) { | |
42 | log_err("%s: cmdprio_percentage option and mutually exclusive " | |
43 | "prio or prioclass option is set, exiting\n", | |
44 | to->name); | |
45 | return 1; | |
46 | } | |
47 | ||
48 | *has_cmdprio = has_cmdprio_percentage; | |
49 | ||
50 | return 0; | |
51 | } | |
52 | ||
53 | #endif |