mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-16 11:24:00 +00:00
f2fs: add offset check routine before punch_hole() in f2fs_fallocate()
In the punch_hole(), if offset bigger than inode size, it returns SUCCESS. Then f2fs_fallocate() will update time and dirty mark. In that case, inode has not been modified actually. So I have added offset check routine that prevent to call the punch_hole(). Signed-off-by: Taehee Yoo <ap420073@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
f0c9cadae6
commit
587c0a4255
1 changed files with 7 additions and 6 deletions
|
@ -718,10 +718,6 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
|
||||||
if (!S_ISREG(inode->i_mode))
|
if (!S_ISREG(inode->i_mode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
/* skip punching hole beyond i_size */
|
|
||||||
if (offset >= inode->i_size)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (f2fs_has_inline_data(inode)) {
|
if (f2fs_has_inline_data(inode)) {
|
||||||
ret = f2fs_convert_inline_inode(inode);
|
ret = f2fs_convert_inline_inode(inode);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -830,15 +826,19 @@ static long f2fs_fallocate(struct file *file, int mode,
|
||||||
loff_t offset, loff_t len)
|
loff_t offset, loff_t len)
|
||||||
{
|
{
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
long ret;
|
long ret = 0;
|
||||||
|
|
||||||
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
|
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
|
|
||||||
if (mode & FALLOC_FL_PUNCH_HOLE)
|
if (mode & FALLOC_FL_PUNCH_HOLE) {
|
||||||
|
if (offset >= inode->i_size)
|
||||||
|
goto out;
|
||||||
|
|
||||||
ret = punch_hole(inode, offset, len);
|
ret = punch_hole(inode, offset, len);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = expand_inode_data(inode, offset, len, mode);
|
ret = expand_inode_data(inode, offset, len, mode);
|
||||||
|
|
||||||
|
@ -847,6 +847,7 @@ static long f2fs_fallocate(struct file *file, int mode,
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
|
|
||||||
trace_f2fs_fallocate(inode, mode, offset, len, ret);
|
trace_f2fs_fallocate(inode, mode, offset, len, ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue