Skip to content

Commit

Permalink
fs: prevent doing FALLOC_FL_ZERO_RANGE on append only file
Browse files Browse the repository at this point in the history
Currently punch hole and collapse range fallocate operation are not
allowed on append only file. This should be case for zero range as well.
Fix it by allowing only pure fallocate (possibly with keep size set).

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Lukas Czerner authored and Theodore Ts'o committed Apr 12, 2014
1 parent 9ef06ce commit 8fc61d9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,9 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return -EBADF;

/*
* It's not possible to punch hole or perform collapse range
* on append only file
* We can only allow pure fallocate on append only files
*/
if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE)
&& IS_APPEND(inode))
if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
return -EPERM;

if (IS_IMMUTABLE(inode))
Expand Down

0 comments on commit 8fc61d9

Please sign in to comment.