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

ext4: use ext4_fc_tl_mem in fast-commit replay path

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: dcc5827484d6 ("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>

authored by

Eric Biggers and committed by
Theodore Ts'o
11768cfd 3478c83c

+26 -18
+26 -18
fs/ext4/fast_commit.c
··· 1332 1332 char *dname; 1333 1333 }; 1334 1334 1335 + /* Same as struct ext4_fc_tl, but uses native endianness fields */ 1336 + struct ext4_fc_tl_mem { 1337 + u16 fc_tag; 1338 + u16 fc_len; 1339 + }; 1340 + 1335 1341 static inline void tl_to_darg(struct dentry_info_args *darg, 1336 - struct ext4_fc_tl *tl, u8 *val) 1342 + struct ext4_fc_tl_mem *tl, u8 *val) 1337 1343 { 1338 1344 struct ext4_fc_dentry_info fcd; 1339 1345 ··· 1351 1345 darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info); 1352 1346 } 1353 1347 1354 - static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val) 1348 + static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val) 1355 1349 { 1356 - memcpy(tl, val, EXT4_FC_TAG_BASE_LEN); 1357 - tl->fc_len = le16_to_cpu(tl->fc_len); 1358 - tl->fc_tag = le16_to_cpu(tl->fc_tag); 1350 + struct ext4_fc_tl tl_disk; 1351 + 1352 + memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN); 1353 + tl->fc_len = le16_to_cpu(tl_disk.fc_len); 1354 + tl->fc_tag = le16_to_cpu(tl_disk.fc_tag); 1359 1355 } 1360 1356 1361 1357 /* Unlink replay function */ 1362 - static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl, 1363 - u8 *val) 1358 + static int ext4_fc_replay_unlink(struct super_block *sb, 1359 + struct ext4_fc_tl_mem *tl, u8 *val) 1364 1360 { 1365 1361 struct inode *inode, *old_parent; 1366 1362 struct qstr entry; ··· 1459 1451 } 1460 1452 1461 1453 /* Link replay function */ 1462 - static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl, 1463 - u8 *val) 1454 + static int ext4_fc_replay_link(struct super_block *sb, 1455 + struct ext4_fc_tl_mem *tl, u8 *val) 1464 1456 { 1465 1457 struct inode *inode; 1466 1458 struct dentry_info_args darg; ··· 1514 1506 /* 1515 1507 * Inode replay function 1516 1508 */ 1517 - static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl, 1518 - u8 *val) 1509 + static int ext4_fc_replay_inode(struct super_block *sb, 1510 + struct ext4_fc_tl_mem *tl, u8 *val) 1519 1511 { 1520 1512 struct ext4_fc_inode fc_inode; 1521 1513 struct ext4_inode *raw_inode; ··· 1617 1609 * inode for which we are trying to create a dentry here, should already have 1618 1610 * been replayed before we start here. 1619 1611 */ 1620 - static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl, 1621 - u8 *val) 1612 + static int ext4_fc_replay_create(struct super_block *sb, 1613 + struct ext4_fc_tl_mem *tl, u8 *val) 1622 1614 { 1623 1615 int ret = 0; 1624 1616 struct inode *inode = NULL; ··· 1716 1708 1717 1709 /* Replay add range tag */ 1718 1710 static int ext4_fc_replay_add_range(struct super_block *sb, 1719 - struct ext4_fc_tl *tl, u8 *val) 1711 + struct ext4_fc_tl_mem *tl, u8 *val) 1720 1712 { 1721 1713 struct ext4_fc_add_range fc_add_ex; 1722 1714 struct ext4_extent newex, *ex; ··· 1836 1828 1837 1829 /* Replay DEL_RANGE tag */ 1838 1830 static int 1839 - ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl, 1840 - u8 *val) 1831 + ext4_fc_replay_del_range(struct super_block *sb, 1832 + struct ext4_fc_tl_mem *tl, u8 *val) 1841 1833 { 1842 1834 struct inode *inode; 1843 1835 struct ext4_fc_del_range lrange; ··· 2033 2025 struct ext4_fc_replay_state *state; 2034 2026 int ret = JBD2_FC_REPLAY_CONTINUE; 2035 2027 struct ext4_fc_add_range ext; 2036 - struct ext4_fc_tl tl; 2028 + struct ext4_fc_tl_mem tl; 2037 2029 struct ext4_fc_tail tail; 2038 2030 __u8 *start, *end, *cur, *val; 2039 2031 struct ext4_fc_head head; ··· 2152 2144 { 2153 2145 struct super_block *sb = journal->j_private; 2154 2146 struct ext4_sb_info *sbi = EXT4_SB(sb); 2155 - struct ext4_fc_tl tl; 2147 + struct ext4_fc_tl_mem tl; 2156 2148 __u8 *start, *end, *cur, *val; 2157 2149 int ret = JBD2_FC_REPLAY_CONTINUE; 2158 2150 struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state;