Skip to content

Commit 4cde00d

Browse files
author
Jaegeuk Kim
committed
f2fs: attach inline_data after setting compression
This fixes the below corruption. [345393.335389] F2FS-fs (vdb): sanity_check_inode: inode (ino=6d0, mode=33206) should not have inline_data, run fsck to fix Cc: <[email protected]> Fixes: 677a82b ("f2fs: fix to do sanity check for inline inode") Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent f2906aa commit 4cde00d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

fs/f2fs/namei.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
8989
if (test_opt(sbi, INLINE_XATTR))
9090
set_inode_flag(inode, FI_INLINE_XATTR);
9191

92-
if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode))
93-
set_inode_flag(inode, FI_INLINE_DATA);
9492
if (f2fs_may_inline_dentry(inode))
9593
set_inode_flag(inode, FI_INLINE_DENTRY);
9694

@@ -107,10 +105,6 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
107105

108106
f2fs_init_extent_tree(inode, NULL);
109107

110-
stat_inc_inline_xattr(inode);
111-
stat_inc_inline_inode(inode);
112-
stat_inc_inline_dir(inode);
113-
114108
F2FS_I(inode)->i_flags =
115109
f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED);
116110

@@ -127,6 +121,14 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
127121
set_compress_context(inode);
128122
}
129123

124+
/* Should enable inline_data after compression set */
125+
if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode))
126+
set_inode_flag(inode, FI_INLINE_DATA);
127+
128+
stat_inc_inline_xattr(inode);
129+
stat_inc_inline_inode(inode);
130+
stat_inc_inline_dir(inode);
131+
130132
f2fs_set_inode_flags(inode);
131133

132134
trace_f2fs_new_inode(inode, 0);
@@ -325,6 +327,9 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
325327
if (!is_extension_exist(name, ext[i], false))
326328
continue;
327329

330+
/* Do not use inline_data with compression */
331+
stat_dec_inline_inode(inode);
332+
clear_inode_flag(inode, FI_INLINE_DATA);
328333
set_compress_context(inode);
329334
return;
330335
}

0 commit comments

Comments
 (0)