summaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-10-03 09:11:14 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2016-10-03 09:11:14 -0700
commit71be6b4942dd64bc17728f82f787be98fd8afed7 (patch)
treec5a219e8c9d574051b01551d6e24012519213a03 /fs/open.c
parent0a6eab8bd4e0120d49511acbb294797d96ef9e4a (diff)
downloadlinux-71be6b4942dd64bc17728f82f787be98fd8afed7.tar.bz2
vfs: add a FALLOC_FL_UNSHARE mode to fallocate to unshare a range of blocks
Add a new fallocate mode flag that explicitly unshares blocks on filesystems that support such features. The new flag can only be used with an allocate-mode fallocate call. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/open.c b/fs/open.c
index 4fd6e256f4f4..d58525dda28d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -256,6 +256,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
(mode & ~FALLOC_FL_INSERT_RANGE))
return -EINVAL;
+ /* Unshare range should only be used with allocate mode. */
+ if ((mode & FALLOC_FL_UNSHARE_RANGE) &&
+ (mode & ~(FALLOC_FL_UNSHARE_RANGE | FALLOC_FL_KEEP_SIZE)))
+ return -EINVAL;
+
if (!(file->f_mode & FMODE_WRITE))
return -EBADF;