Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse bugfix from Miklos Szeredi: "This fixes a race between fallocate() and truncate()" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: hold i_mutex in fuse_file_fallocate()
This commit is contained in:
@@ -2470,13 +2470,16 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
|
|||||||
.mode = mode
|
.mode = mode
|
||||||
};
|
};
|
||||||
int err;
|
int err;
|
||||||
|
bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) ||
|
||||||
|
(mode & FALLOC_FL_PUNCH_HOLE);
|
||||||
|
|
||||||
if (fc->no_fallocate)
|
if (fc->no_fallocate)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (mode & FALLOC_FL_PUNCH_HOLE) {
|
if (lock_inode) {
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
fuse_set_nowrite(inode);
|
if (mode & FALLOC_FL_PUNCH_HOLE)
|
||||||
|
fuse_set_nowrite(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
req = fuse_get_req_nopages(fc);
|
req = fuse_get_req_nopages(fc);
|
||||||
@@ -2511,8 +2514,9 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
|
|||||||
fuse_invalidate_attr(inode);
|
fuse_invalidate_attr(inode);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (mode & FALLOC_FL_PUNCH_HOLE) {
|
if (lock_inode) {
|
||||||
fuse_release_nowrite(inode);
|
if (mode & FALLOC_FL_PUNCH_HOLE)
|
||||||
|
fuse_release_nowrite(inode);
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user