Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: Move enum rw_hint into a new header file

Move enum rw_hint into a new header file to prepare for using this data
type in the block layer. Add the attribute __packed to reduce the space
occupied by instances of this data type from four bytes to one byte.
Change the data type of i_write_hint from u8 into enum rw_hint.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Chao Yu <chao@kernel.org> # for the F2FS part
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240202203926.2478590-5-bvanassche@acm.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Bart Van Assche and committed by
Christian Brauner
fe3944fb 1505ba06

+29 -14
+1
fs/f2fs/f2fs.h
··· 24 24 #include <linux/blkdev.h> 25 25 #include <linux/quotaops.h> 26 26 #include <linux/part_stat.h> 27 + #include <linux/rw_hint.h> 27 28 #include <crypto/hash.h> 28 29 29 30 #include <linux/fscrypt.h>
+1
fs/fcntl.c
··· 27 27 #include <linux/memfd.h> 28 28 #include <linux/compat.h> 29 29 #include <linux/mount.h> 30 + #include <linux/rw_hint.h> 30 31 31 32 #include <linux/poll.h> 32 33 #include <asm/siginfo.h>
+1
fs/inode.c
··· 20 20 #include <linux/ratelimit.h> 21 21 #include <linux/list_lru.h> 22 22 #include <linux/iversion.h> 23 + #include <linux/rw_hint.h> 23 24 #include <trace/events/writeback.h> 24 25 #include "internal.h" 25 26
+2 -14
include/linux/fs.h
··· 43 43 #include <linux/cred.h> 44 44 #include <linux/mnt_idmapping.h> 45 45 #include <linux/slab.h> 46 + #include <linux/rw_hint.h> 46 47 47 48 #include <asm/byteorder.h> 48 49 #include <uapi/linux/fs.h> ··· 309 308 struct address_space; 310 309 struct writeback_control; 311 310 struct readahead_control; 312 - 313 - /* 314 - * Write life time hint values. 315 - * Stored in struct inode as u8. 316 - */ 317 - enum rw_hint { 318 - WRITE_LIFE_NOT_SET = 0, 319 - WRITE_LIFE_NONE = RWH_WRITE_LIFE_NONE, 320 - WRITE_LIFE_SHORT = RWH_WRITE_LIFE_SHORT, 321 - WRITE_LIFE_MEDIUM = RWH_WRITE_LIFE_MEDIUM, 322 - WRITE_LIFE_LONG = RWH_WRITE_LIFE_LONG, 323 - WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, 324 - }; 325 311 326 312 /* Match RWF_* bits to IOCB bits */ 327 313 #define IOCB_HIPRI (__force int) RWF_HIPRI ··· 665 677 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 666 678 unsigned short i_bytes; 667 679 u8 i_blkbits; 668 - u8 i_write_hint; 680 + enum rw_hint i_write_hint; 669 681 blkcnt_t i_blocks; 670 682 671 683 #ifdef __NEED_I_SIZE_ORDERED
+24
include/linux/rw_hint.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_RW_HINT_H 3 + #define _LINUX_RW_HINT_H 4 + 5 + #include <linux/build_bug.h> 6 + #include <linux/compiler_attributes.h> 7 + #include <uapi/linux/fcntl.h> 8 + 9 + /* Block storage write lifetime hint values. */ 10 + enum rw_hint { 11 + WRITE_LIFE_NOT_SET = RWH_WRITE_LIFE_NOT_SET, 12 + WRITE_LIFE_NONE = RWH_WRITE_LIFE_NONE, 13 + WRITE_LIFE_SHORT = RWH_WRITE_LIFE_SHORT, 14 + WRITE_LIFE_MEDIUM = RWH_WRITE_LIFE_MEDIUM, 15 + WRITE_LIFE_LONG = RWH_WRITE_LIFE_LONG, 16 + WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, 17 + } __packed; 18 + 19 + /* Sparse ignores __packed annotations on enums, hence the #ifndef below. */ 20 + #ifndef __CHECKER__ 21 + static_assert(sizeof(enum rw_hint) == 1); 22 + #endif 23 + 24 + #endif /* _LINUX_RW_HINT_H */