aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fuse/file.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index e570081f9f76..35f281033142 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2470,13 +2470,16 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
2470 .mode = mode 2470 .mode = mode
2471 }; 2471 };
2472 int err; 2472 int err;
2473 bool lock_inode = !(mode & FALLOC_FL_KEEP_SIZE) ||
2474 (mode & FALLOC_FL_PUNCH_HOLE);
2473 2475
2474 if (fc->no_fallocate) 2476 if (fc->no_fallocate)
2475 return -EOPNOTSUPP; 2477 return -EOPNOTSUPP;
2476 2478
2477 if (mode & FALLOC_FL_PUNCH_HOLE) { 2479 if (lock_inode) {
2478 mutex_lock(&inode->i_mutex); 2480 mutex_lock(&inode->i_mutex);
2479 fuse_set_nowrite(inode); 2481 if (mode & FALLOC_FL_PUNCH_HOLE)
2482 fuse_set_nowrite(inode);
2480 } 2483 }
2481 2484
2482 req = fuse_get_req_nopages(fc); 2485 req = fuse_get_req_nopages(fc);
@@ -2511,8 +2514,9 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
2511 fuse_invalidate_attr(inode); 2514 fuse_invalidate_attr(inode);
2512 2515
2513out: 2516out:
2514 if (mode & FALLOC_FL_PUNCH_HOLE) { 2517 if (lock_inode) {
2515 fuse_release_nowrite(inode); 2518 if (mode & FALLOC_FL_PUNCH_HOLE)
2519 fuse_release_nowrite(inode);
2516 mutex_unlock(&inode->i_mutex); 2520 mutex_unlock(&inode->i_mutex);
2517 } 2521 }
2518 2522