mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
f2fs: compress: fix to relocate check condition in f2fs_{release,reserve}_compress_blocks()
[ Upstream commit7c5dffb3d9] Compress flag should be checked after inode lock held to avoid racing w/ f2fs_setflags_common(), fix it. Fixes:4c8ff7095b("f2fs: support data compression") Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com> Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
bb1f43ffac
commit
eeac6ee8f6
@@ -3525,9 +3525,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
|
|||||||
if (!f2fs_sb_has_compression(sbi))
|
if (!f2fs_sb_has_compression(sbi))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (!f2fs_compressed_file(inode))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (f2fs_readonly(sbi->sb))
|
if (f2fs_readonly(sbi->sb))
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
|
||||||
@@ -3546,7 +3543,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
|
if (!f2fs_compressed_file(inode) ||
|
||||||
|
is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -3707,9 +3705,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
|
|||||||
if (!f2fs_sb_has_compression(sbi))
|
if (!f2fs_sb_has_compression(sbi))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (!f2fs_compressed_file(inode))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (f2fs_readonly(sbi->sb))
|
if (f2fs_readonly(sbi->sb))
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
|
||||||
@@ -3721,7 +3716,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
|
|||||||
|
|
||||||
inode_lock(inode);
|
inode_lock(inode);
|
||||||
|
|
||||||
if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
|
if (!f2fs_compressed_file(inode) ||
|
||||||
|
!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto unlock_inode;
|
goto unlock_inode;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user