]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/nfs/nfs4file.c
nfs: Add DEALLOCATE support
[karo-tx-linux.git] / fs / nfs / nfs4file.c
index f78e9fd0735a170884b0053c288a198cb24081b1..8b46389c4c5b814806979b66348121afe0590090 100644 (file)
@@ -145,7 +145,7 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t
        if (!S_ISREG(inode->i_mode))
                return -EOPNOTSUPP;
 
-       if (mode != 0)
+       if ((mode != 0) && (mode != (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE)))
                return -EOPNOTSUPP;
 
        ret = inode_newsize_ok(inode, offset + len);
@@ -153,7 +153,10 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t
                return ret;
 
        mutex_lock(&inode->i_mutex);
-       ret = nfs42_proc_allocate(filep, offset, len);
+       if (mode & FALLOC_FL_PUNCH_HOLE)
+               ret = nfs42_proc_deallocate(filep, offset, len);
+       else
+               ret = nfs42_proc_allocate(filep, offset, len);
        mutex_unlock(&inode->i_mutex);
 
        nfs_zap_caches(inode);