]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: Move enum rw_hint into a new header file
authorBart Van Assche <bvanassche@acm.org>
Fri, 2 Feb 2024 20:39:23 +0000 (12:39 -0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 6 Feb 2024 13:30:48 +0000 (14:30 +0100)
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>
fs/f2fs/f2fs.h
fs/fcntl.c
fs/inode.c
include/linux/fs.h
include/linux/rw_hint.h [new file with mode: 0644]

index 65294e3b0bef880a424c480ba4f4997b23c6b59c..01fde6d44bf618afb3e04b7ab278711358e670eb 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/blkdev.h>
 #include <linux/quotaops.h>
 #include <linux/part_stat.h>
+#include <linux/rw_hint.h>
 #include <crypto/hash.h>
 
 #include <linux/fscrypt.h>
index d2b15351ab8e6562783d52eda871bb94a7d5f3dd..00be0a710bbabc882ca46121e73c314345d00c89 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/memfd.h>
 #include <linux/compat.h>
 #include <linux/mount.h>
+#include <linux/rw_hint.h>
 
 #include <linux/poll.h>
 #include <asm/siginfo.h>
index 91048c4c9c9e7d1079d375afe64383c74f0c3c81..1aba6c0bf26ac1103b81bc4b2314db89ab5c5a17 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/ratelimit.h>
 #include <linux/list_lru.h>
 #include <linux/iversion.h>
+#include <linux/rw_hint.h>
 #include <trace/events/writeback.h>
 #include "internal.h"
 
index ed5966a70495129be1d6729eed2918240db62df1..bdabda5dc3645eb1c576ac250f48c949a4289b1a 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/cred.h>
 #include <linux/mnt_idmapping.h>
 #include <linux/slab.h>
+#include <linux/rw_hint.h>
 
 #include <asm/byteorder.h>
 #include <uapi/linux/fs.h>
@@ -309,19 +310,6 @@ struct address_space;
 struct writeback_control;
 struct readahead_control;
 
-/*
- * Write life time hint values.
- * Stored in struct inode as u8.
- */
-enum rw_hint {
-       WRITE_LIFE_NOT_SET      = 0,
-       WRITE_LIFE_NONE         = RWH_WRITE_LIFE_NONE,
-       WRITE_LIFE_SHORT        = RWH_WRITE_LIFE_SHORT,
-       WRITE_LIFE_MEDIUM       = RWH_WRITE_LIFE_MEDIUM,
-       WRITE_LIFE_LONG         = RWH_WRITE_LIFE_LONG,
-       WRITE_LIFE_EXTREME      = RWH_WRITE_LIFE_EXTREME,
-};
-
 /* Match RWF_* bits to IOCB bits */
 #define IOCB_HIPRI             (__force int) RWF_HIPRI
 #define IOCB_DSYNC             (__force int) RWF_DSYNC
@@ -677,7 +665,7 @@ struct inode {
        spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
        unsigned short          i_bytes;
        u8                      i_blkbits;
-       u8                      i_write_hint;
+       enum rw_hint            i_write_hint;
        blkcnt_t                i_blocks;
 
 #ifdef __NEED_I_SIZE_ORDERED
diff --git a/include/linux/rw_hint.h b/include/linux/rw_hint.h
new file mode 100644 (file)
index 0000000..309ca72
--- /dev/null
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_RW_HINT_H
+#define _LINUX_RW_HINT_H
+
+#include <linux/build_bug.h>
+#include <linux/compiler_attributes.h>
+#include <uapi/linux/fcntl.h>
+
+/* Block storage write lifetime hint values. */
+enum rw_hint {
+       WRITE_LIFE_NOT_SET      = RWH_WRITE_LIFE_NOT_SET,
+       WRITE_LIFE_NONE         = RWH_WRITE_LIFE_NONE,
+       WRITE_LIFE_SHORT        = RWH_WRITE_LIFE_SHORT,
+       WRITE_LIFE_MEDIUM       = RWH_WRITE_LIFE_MEDIUM,
+       WRITE_LIFE_LONG         = RWH_WRITE_LIFE_LONG,
+       WRITE_LIFE_EXTREME      = RWH_WRITE_LIFE_EXTREME,
+} __packed;
+
+/* Sparse ignores __packed annotations on enums, hence the #ifndef below. */
+#ifndef __CHECKER__
+static_assert(sizeof(enum rw_hint) == 1);
+#endif
+
+#endif /* _LINUX_RW_HINT_H */