]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.51/f2fs-fix-to-use-inline-space-only-if-inline_xattr-is.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / f2fs-fix-to-use-inline-space-only-if-inline_xattr-is.patch
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
5
6 [ Upstream commit 622927f3b8809206f6da54a6a7ed4df1a7770fce ]
7
8 With below mkfs and mount option:
9
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
12
13 We may miss xattr data with below testcase:
14 - mkdir dir
15 - setfattr -n "user.name" -v 0 dir
16 - for ((i = 0; i < 190; i++)) do touch dir/$i; done
17 - umount
18 - mount
19 - getfattr -n "user.name" dir
20
21 user.name: No such attribute
22
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
26 data missed.
27
28 Let's use inline xattr space only if inline_xattr flag is set on inode
29 to fix this iusse.
30
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>
35 ---
36 fs/f2fs/f2fs.h | 4 +++-
37 1 file changed, 3 insertions(+), 1 deletion(-)
38
39 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
40 index 64f970cca1b4..44ea7ac69ef4 100644
41 --- a/fs/f2fs/f2fs.h
42 +++ b/fs/f2fs/f2fs.h
43 @@ -2497,7 +2497,9 @@ static inline void *inline_xattr_addr(struct inode *inode, struct page *page)
44
45 static inline int inline_xattr_size(struct inode *inode)
46 {
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);
50 + return 0;
51 }
52
53 static inline int f2fs_has_inline_data(struct inode *inode)
54 --
55 2.20.1
56