fs/ntfs3: Forbid FALLOC_FL_PUNCH_HOLE for normal files
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 28 Sep 2021 17:04:10 +0000 (20:04 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 5 Oct 2021 14:01:55 +0000 (17:01 +0300)
FALLOC_FL_PUNCH_HOLE isn't allowed with normal files.
Filesystem must remember info about hole, but for normal file
we can only zero it and forget.

Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
Now xfstests generic/016 generic/021 generic/022 pass.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/file.c

index 5fb3508e5422cc6654381897d6fdb4a204a543a4..43b1451bff539576cd03c0f624708bf65b959270 100644 (file)
@@ -587,8 +587,11 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
                truncate_pagecache(inode, vbo_down);
 
                if (!is_sparsed(ni) && !is_compressed(ni)) {
-                       /* Normal file. */
-                       err = ntfs_zero_range(inode, vbo, end);
+                       /*
+                        * Normal file, can't make hole.
+                        * TODO: Try to find way to save info about hole.
+                        */
+                       err = -EOPNOTSUPP;
                        goto out;
                }