Skip to contentSkip to conversation

fs/ntfs3: Forbid FALLOC_FL_PUNCH_HOLE for normal files

PATCH Superseded Konstantin Komarov 2 participants 2 messages Sep 28, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Konstantin Komarov

author maintainer
#0 lore raw

PATCH 1/1 fs/ntfs3: Forbid FALLOC_FL_PUNCH_HOLE for normal files

FALLOC_FL_PUNCH_HOLE isn't allowed with normal files. Fixes xfstest generic/016 021 022

---
 fs/ntfs3/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/file.c +2 -2
index 5fb3508e5422..02ca665baa5f 100644
@@ -587,8 +587,8 @@ 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. */
+			err = -EOPNOTSUPP;
 			goto out;
 		}
 
Signature · 1 line
2.33.0
#1 lore raw
Quoted 1 line · Konstantin Komarov

FALLOC_FL_PUNCH_HOLE isn't allowed with normal files.

But is this absolute or just for now it can't? In my mind this can be done, but you are expert here. Please write about it here. This will help who ever will implement this in future. Example why ntfs_zero_range did not punch a hole for normal file. You did actually implement that function for this purpose right?

Quoted 1 line

Fixes xfstest generic/016 021 022

Lot of grepping is done with these so use full format generic/xxx with each of these.

Also this affects also to these, but I did not look if there is other problems than punching.

generic/012
generic/177
generic/255
generic/316

Add fixes tag here.

Quoted 11 lines
---
 fs/ntfs3/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/file.c +0 -0
index 5fb3508e5422..02ca665baa5f 100644

fs/ntfs3/file.c static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len) · line 590

Quoted 6 lines
fs/ntfs3/file.c +1 -2
@@ -587,8 +587,8 @@ 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. */

If this is just for now plese write example

			/* TODO: Can't make hole to normal files yet. */
Quoted 7 lines
fs/ntfs3/file.c +1 -0
+			err = -EOPNOTSUPP;
 			goto out;
 		}
 
Signature · 1 line
2.33.0