1 From a50b1f50e2a6d1223ea7e68af2c76c6da09c415f Mon Sep 17 00:00:00 2001
2 From: Chao Yu <yuchao0@huawei.com>
3 Date: Thu, 11 Apr 2019 11:48:10 +0800
4 Subject: f2fs: fix to use inline space only if inline_xattr is enable
6 [ Upstream commit 622927f3b8809206f6da54a6a7ed4df1a7770fce ]
8 With below mkfs and mount option:
10 MKFS_OPTIONS -- -O extra_attr -O project_quota -O inode_checksum -O flexible_inline_xattr -O inode_crtime -f
11 MOUNT_OPTIONS -- -o noinline_xattr
13 We may miss xattr data with below testcase:
15 - setfattr -n "user.name" -v 0 dir
16 - for ((i = 0; i < 190; i++)) do touch dir/$i; done
19 - getfattr -n "user.name" dir
21 user.name: No such attribute
23 The root cause is that we persist xattr data into reserved inline xattr
24 space, even if inline_xattr is not enable in inline directory inode, after
25 inline dentry conversion, reserved space no longer exists, so that xattr
28 Let's use inline xattr space only if inline_xattr flag is set on inode
31 Fixes: 6afc662e68b5 ("f2fs: support flexible inline xattr size")
32 Signed-off-by: Chao Yu <yuchao0@huawei.com>
33 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
34 Signed-off-by: Sasha Levin <sashal@kernel.org>
36 fs/f2fs/f2fs.h | 4 +++-
37 1 file changed, 3 insertions(+), 1 deletion(-)
39 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
40 index 64f970cca1b4..44ea7ac69ef4 100644
43 @@ -2497,7 +2497,9 @@ static inline void *inline_xattr_addr(struct inode *inode, struct page *page)
45 static inline int inline_xattr_size(struct inode *inode)
47 - return get_inline_xattr_addrs(inode) * sizeof(__le32);
48 + if (f2fs_has_inline_xattr(inode))
49 + return get_inline_xattr_addrs(inode) * sizeof(__le32);
53 static inline int f2fs_has_inline_data(struct inode *inode)