diff options
author | Adam Manzanares | 2018-05-22 10:52:18 -0700 |
---|---|---|
committer | Al Viro | 2018-05-31 10:50:54 -0400 |
commit | fc28724d67c90ff48b976e0687caf79993160bed (patch) | |
tree | 75a01e8f9ee260b9408c338e7a351e7024127940 /include/linux/fs.h | |
parent | aa43457799f715d76cb77342baab0615877e2b8a (diff) |
fs: Convert kiocb rw_hint from enum to u16
In order to avoid kiocb bloat for per command iopriority support, rw_hint
is converted from enum to a u16. Added a guard around ki_hint assignment.
Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 4b6045ebb2f2..b432fc3feb93 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -299,7 +299,7 @@ struct kiocb { void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); void *private; int ki_flags; - enum rw_hint ki_hint; + u16 ki_hint; } __randomize_layout; static inline bool is_sync_kiocb(struct kiocb *kiocb) @@ -1929,12 +1929,21 @@ static inline enum rw_hint file_write_hint(struct file *file) static inline int iocb_flags(struct file *file); +static inline u16 ki_hint_validate(enum rw_hint hint) +{ + typeof(((struct kiocb *)0)->ki_hint) max_hint = -1; + + if (hint <= max_hint) + return hint; + return 0; +} + static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) { *kiocb = (struct kiocb) { .ki_filp = filp, .ki_flags = iocb_flags(filp), - .ki_hint = file_write_hint(filp), + .ki_hint = ki_hint_validate(file_write_hint(filp)), }; } |