]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ext4: use ext4_fc_tl_mem in fast-commit replay path
authorEric Biggers <ebiggers@google.com>
Sat, 17 Dec 2022 05:02:12 +0000 (21:02 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:22 +0000 (13:55 +0100)
[ Upstream commit 643137ddefe478409b2b20d9968b7aea8be0f0be ]

To avoid 'sparse' warnings about missing endianness conversions, don't
store native endianness values into struct ext4_fc_tl.  Instead, use a
separate struct type, ext4_fc_tl_mem.

Fixes: c9df516c7f6b ("ext4: factor out ext4_fc_get_tl()")
Cc: Ye Bin <yebin10@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20221217050212.150665-1-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext4/fast_commit.c

index 7ed71c652f67f9c461110a3fb5c3695546406924..1110bfa0a5b732e708f5cc6e85ae97e5b89f1502 100644 (file)
@@ -1354,8 +1354,14 @@ struct dentry_info_args {
        char *dname;
 };
 
+/* Same as struct ext4_fc_tl, but uses native endianness fields */
+struct ext4_fc_tl_mem {
+       u16 fc_tag;
+       u16 fc_len;
+};
+
 static inline void tl_to_darg(struct dentry_info_args *darg,
-                             struct ext4_fc_tl *tl, u8 *val)
+                             struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct ext4_fc_dentry_info fcd;
 
@@ -1367,16 +1373,18 @@ static inline void tl_to_darg(struct dentry_info_args *darg,
        darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info);
 }
 
-static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
+static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val)
 {
-       memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
-       tl->fc_len = le16_to_cpu(tl->fc_len);
-       tl->fc_tag = le16_to_cpu(tl->fc_tag);
+       struct ext4_fc_tl tl_disk;
+
+       memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN);
+       tl->fc_len = le16_to_cpu(tl_disk.fc_len);
+       tl->fc_tag = le16_to_cpu(tl_disk.fc_tag);
 }
 
 /* Unlink replay function */
-static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl,
-                                u8 *val)
+static int ext4_fc_replay_unlink(struct super_block *sb,
+                                struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct inode *inode, *old_parent;
        struct qstr entry;
@@ -1473,8 +1481,8 @@ out:
 }
 
 /* Link replay function */
-static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl,
-                              u8 *val)
+static int ext4_fc_replay_link(struct super_block *sb,
+                              struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct inode *inode;
        struct dentry_info_args darg;
@@ -1528,8 +1536,8 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino)
 /*
  * Inode replay function
  */
-static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
-                               u8 *val)
+static int ext4_fc_replay_inode(struct super_block *sb,
+                               struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct ext4_fc_inode fc_inode;
        struct ext4_inode *raw_inode;
@@ -1631,8 +1639,8 @@ out:
  * inode for which we are trying to create a dentry here, should already have
  * been replayed before we start here.
  */
-static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl,
-                                u8 *val)
+static int ext4_fc_replay_create(struct super_block *sb,
+                                struct ext4_fc_tl_mem *tl, u8 *val)
 {
        int ret = 0;
        struct inode *inode = NULL;
@@ -1730,7 +1738,7 @@ int ext4_fc_record_regions(struct super_block *sb, int ino,
 
 /* Replay add range tag */
 static int ext4_fc_replay_add_range(struct super_block *sb,
-                                   struct ext4_fc_tl *tl, u8 *val)
+                                   struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct ext4_fc_add_range fc_add_ex;
        struct ext4_extent newex, *ex;
@@ -1850,8 +1858,8 @@ out:
 
 /* Replay DEL_RANGE tag */
 static int
-ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl,
-                        u8 *val)
+ext4_fc_replay_del_range(struct super_block *sb,
+                        struct ext4_fc_tl_mem *tl, u8 *val)
 {
        struct inode *inode;
        struct ext4_fc_del_range lrange;
@@ -2047,7 +2055,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
        struct ext4_fc_replay_state *state;
        int ret = JBD2_FC_REPLAY_CONTINUE;
        struct ext4_fc_add_range ext;
-       struct ext4_fc_tl tl;
+       struct ext4_fc_tl_mem tl;
        struct ext4_fc_tail tail;
        __u8 *start, *end, *cur, *val;
        struct ext4_fc_head head;
@@ -2166,7 +2174,7 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
 {
        struct super_block *sb = journal->j_private;
        struct ext4_sb_info *sbi = EXT4_SB(sb);
-       struct ext4_fc_tl tl;
+       struct ext4_fc_tl_mem tl;
        __u8 *start, *end, *cur, *val;
        int ret = JBD2_FC_REPLAY_CONTINUE;
        struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state;