Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dbc7469 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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()
parents f97f7d2d 14c14414
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -2470,12 +2470,15 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
		.mode = mode
	};
	int err;
	bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) ||
			   (mode & FALLOC_FL_PUNCH_HOLE);

	if (fc->no_fallocate)
		return -EOPNOTSUPP;

	if (mode & FALLOC_FL_PUNCH_HOLE) {
	if (lock_inode) {
		mutex_lock(&inode->i_mutex);
		if (mode & FALLOC_FL_PUNCH_HOLE)
			fuse_set_nowrite(inode);
	}

@@ -2511,7 +2514,8 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
	fuse_invalidate_attr(inode);

out:
	if (mode & FALLOC_FL_PUNCH_HOLE) {
	if (lock_inode) {
		if (mode & FALLOC_FL_PUNCH_HOLE)
			fuse_release_nowrite(inode);
		mutex_unlock(&inode->i_mutex);
	}