libaio,io_uring: improve cmdprio_percentage option
[fio.git] / engines / cmdprio.h
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];
13 };
14
15 static int fio_cmdprio_init(struct thread_data *td, struct cmdprio *cmdprio,
16                             bool *has_cmdprio)
17 {
18         struct thread_options *to = &td->o;
19         bool has_cmdprio_percentage = false;
20         int i;
21
22         for (i = 0; i < DDIR_RWDIR_CNT; i++) {
23                 if (cmdprio->percentage[i])
24                         has_cmdprio_percentage = true;
25         }
26
27         /*
28          * Check for option conflicts
29          */
30         if (has_cmdprio_percentage &&
31             (fio_option_is_set(to, ioprio) ||
32              fio_option_is_set(to, ioprio_class))) {
33                 log_err("%s: cmdprio_percentage option and mutually exclusive "
34                         "prio or prioclass option is set, exiting\n",
35                         to->name);
36                 return 1;
37         }
38
39         *has_cmdprio = has_cmdprio_percentage;
40
41         return 0;
42 }
43
44 #endif