Skip to content

Commit 69f3a30

Browse files
Ye Bintytso
authored andcommitted
ext4: introduce ITAIL helper
Introduce ITAIL helper to get the bound of xattr in inode. Signed-off-by: Ye Bin <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent f6fc158 commit 69f3a30

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

fs/ext4/xattr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
649649
return error;
650650
raw_inode = ext4_raw_inode(&iloc);
651651
header = IHDR(inode, raw_inode);
652-
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
652+
end = ITAIL(inode, raw_inode);
653653
error = xattr_check_inode(inode, header, end);
654654
if (error)
655655
goto cleanup;
@@ -793,7 +793,7 @@ ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
793793
return error;
794794
raw_inode = ext4_raw_inode(&iloc);
795795
header = IHDR(inode, raw_inode);
796-
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
796+
end = ITAIL(inode, raw_inode);
797797
error = xattr_check_inode(inode, header, end);
798798
if (error)
799799
goto cleanup;
@@ -879,7 +879,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
879879
goto out;
880880
raw_inode = ext4_raw_inode(&iloc);
881881
header = IHDR(inode, raw_inode);
882-
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
882+
end = ITAIL(inode, raw_inode);
883883
ret = xattr_check_inode(inode, header, end);
884884
if (ret)
885885
goto out;
@@ -2244,7 +2244,7 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
22442244
header = IHDR(inode, raw_inode);
22452245
is->s.base = is->s.first = IFIRST(header);
22462246
is->s.here = is->s.first;
2247-
is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
2247+
is->s.end = ITAIL(inode, raw_inode);
22482248
if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
22492249
error = xattr_check_inode(inode, header, is->s.end);
22502250
if (error)
@@ -2795,7 +2795,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
27952795
*/
27962796

27972797
base = IFIRST(header);
2798-
end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
2798+
end = ITAIL(inode, raw_inode);
27992799
min_offs = end - base;
28002800
total_ino = sizeof(struct ext4_xattr_ibody_header) + sizeof(u32);
28012801

fs/ext4/xattr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ struct ext4_xattr_entry {
6767
((void *)raw_inode + \
6868
EXT4_GOOD_OLD_INODE_SIZE + \
6969
EXT4_I(inode)->i_extra_isize))
70+
#define ITAIL(inode, raw_inode) \
71+
((void *)(raw_inode) + \
72+
EXT4_SB((inode)->i_sb)->s_inode_size)
7073
#define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1))
7174

7275
/*

0 commit comments

Comments
 (0)