mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-13 04:39:36 +02:00
f2fs: fix to relocate check condition in f2fs_fallocate()
[ Upstream commit278a6253a6
] compress and pinfile flag should be checked after inode lock held to avoid race condition, fix it. Fixes:4c8ff7095b
("f2fs: support data compression") Fixes:5fed0be858
("f2fs: do not allow partial truncation on pinned file") 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:
parent
116d824f95
commit
5632bdb4e9
|
@ -1797,15 +1797,6 @@ static long f2fs_fallocate(struct file *file, int mode,
|
||||||
(mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
|
(mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
/*
|
|
||||||
* Pinned file should not support partial truncation since the block
|
|
||||||
* can be used by applications.
|
|
||||||
*/
|
|
||||||
if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
|
|
||||||
(mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
|
|
||||||
FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
|
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
|
||||||
FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
|
FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
|
||||||
FALLOC_FL_INSERT_RANGE))
|
FALLOC_FL_INSERT_RANGE))
|
||||||
|
@ -1813,6 +1804,17 @@ static long f2fs_fallocate(struct file *file, int mode,
|
||||||
|
|
||||||
inode_lock(inode);
|
inode_lock(inode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pinned file should not support partial truncation since the block
|
||||||
|
* can be used by applications.
|
||||||
|
*/
|
||||||
|
if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
|
||||||
|
(mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
|
||||||
|
FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) {
|
||||||
|
ret = -EOPNOTSUPP;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = file_modified(file);
|
ret = file_modified(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user