punch-alternating: prevent punching all extents
PATCH 1/1 punch-alternating: prevent punching all extents
From: Carlos Maiolino <[email protected]>
If by any chance the punch size is >= the interval, we end up punching everything, zeroing out the file.
As this is not a tool to dealloc the whole file, so force the user to pass a configuration that won't cause it to happen.
--- src/punch-alternating.c | 5 +++++ 1 file changed, 5 insertions(+)
src/punch-alternating.c +5 -0
@@ -88,6 +88,11 @@ int main(int argc, char *argv[])usage (argv[0 ]); } +if (size >= interval) { +printf ("Interval must be > size\n" ); +usage (argv[0 ]); + } +if (optind != argc -1 )usage (argv[0 ]);
Signature · 1 line
2.52.0
Quoted 19 lines · On Sun, Dec 21, 2025 at 11:24:50AM +0100, [email protected] wrote:
From: Carlos Maiolino <[email protected]>
If by any chance the punch size is >= the interval, we end up punching everything, zeroing out the file.
As this is not a tool to dealloc the whole file, so force the user to pass a configuration that won't cause it to happen.
Signed-off-by Carlos Maiolino <[email protected]>Signed-off-by Carlos Maiolino <[email protected]>--- src/punch-alternating.c | 5 +++++ 1 file changed, 5 insertions(+)src/punch-alternating.c +0
-0
src/punch-alternating.c int main(int argc, char *argv[]) · line 94
Quoted 7 lines
src/punch-alternating.c +4
-0@@ -88,6 +88,11 @@ int main(int argc, char *argv[])usage (argv[0 ]); } +if (size >= interval) { +printf ("Interval must be > size\n" ); +usage (argv[0 ]); + }
OK, I don't mind adding this checking. May I ask which test case hit this "size >= interval" issue when you ran your test?
Quoted 7 lines
src/punch-alternating.c +1
-0+if (optind != argc -1 )usage (argv[0 ]);Signature · 1 line
2.52.0
Quoted 23 lines · Zorro Lang
Quoted 22 lines · On Sun, Dec 21, 2025 at 11:24:50AM +0100, [email protected] wrote:
From: Carlos Maiolino <[email protected]>
If by any chance the punch size is >= the interval, we end up punching everything, zeroing out the file.
As this is not a tool to dealloc the whole file, so force the user to pass a configuration that won't cause it to happen.
Signed-off-by Carlos Maiolino <[email protected]>Signed-off-by Carlos Maiolino <[email protected]>--- src/punch-alternating.c | 5 +++++ 1 file changed, 5 insertions(+)src/punch-alternating.c +0
-0@@ -88,6 +88,11 @@ int main(int argc, char *argv[])usage (argv[0 ]); }
Quoted 7 lines
src/punch-alternating.c int main(int argc, char *argv[]) · line 94
Quoted 4 lines
src/punch-alternating.c +4
-0+if (size >= interval) { +printf ("Interval must be > size\n" ); +usage (argv[0 ]); + }OK, I don't mind adding this checking. May I ask which test case hit this "size >= interval" issue when you ran your test?
None. I was just using the program to test some other stuff without any specific test.
Quoted 11 lines
Reviewed-by Zorro Lang <[email protected]>Quoted 7 lines
src/punch-alternating.c +1
-0+if (optind != argc -1 )usage (argv[0 ]);Signature · 1 line
2.52.0
Quoted 32 lines · Carlos Maiolino
Quoted 23 lines · Zorro Lang
Quoted 22 lines · On Sun, Dec 21, 2025 at 11:24:50AM +0100, [email protected] wrote:
From: Carlos Maiolino <[email protected]>
If by any chance the punch size is >= the interval, we end up punching everything, zeroing out the file.
As this is not a tool to dealloc the whole file, so force the user to pass a configuration that won't cause it to happen.
Signed-off-by Carlos Maiolino <[email protected]>Signed-off-by Carlos Maiolino <[email protected]>--- src/punch-alternating.c | 5 +++++ 1 file changed, 5 insertions(+)src/punch-alternating.c +0
-0@@ -88,6 +88,11 @@ int main(int argc, char *argv[])usage (argv[0 ]); }Quoted 7 lines
src/punch-alternating.c int main(int argc, char *argv[]) · line 94
Quoted 4 lines
src/punch-alternating.c +4
-0+if (size >= interval) { +printf ("Interval must be > size\n" ); +usage (argv[0 ]); + }OK, I don't mind adding this checking. May I ask which test case hit this "size >= interval" issue when you ran your test?
Quoted 2 lines
None. I was just using the program to test some other stuff without any specific test.
Sure, good to know there's not other issues :) This program is a good tool to do some other tests, especially creates lots of data extents effectively :) I've pushed this patch to patches-in-queue branch, will merge it in next release after testing, feel free to check it.
Thanks,
Zorro
Quoted 13 lines
Quoted 12 lines
Reviewed-by Zorro Lang <[email protected]>Quoted 7 lines
src/punch-alternating.c +1
-0+if (optind != argc -1 )usage (argv[0 ]);Signature · 1 line
2.52.0
Quoted 33 lines · Zorro Lang
Quoted 32 lines · Carlos Maiolino
Quoted 30 lines · Zorro Lang
Quoted 19 lines · On Sun, Dec 21, 2025 at 11:24:50AM +0100, [email protected] wrote:
From: Carlos Maiolino <[email protected]>
If by any chance the punch size is >= the interval, we end up punching everything, zeroing out the file.
As this is not a tool to dealloc the whole file, so force the user to pass a configuration that won't cause it to happen.
Signed-off-by Carlos Maiolino <[email protected]>Signed-off-by Carlos Maiolino <[email protected]>--- src/punch-alternating.c | 5 +++++ 1 file changed, 5 insertions(+)src/punch-alternating.c +0
-0src/punch-alternating.c int main(int argc, char *argv[]) · line 94
Quoted 7 lines
src/punch-alternating.c +4
-0@@ -88,6 +88,11 @@ int main(int argc, char *argv[])usage (argv[0 ]); } +if (size >= interval) { +printf ("Interval must be > size\n" ); +usage (argv[0 ]); + }OK, I don't mind adding this checking. May I ask which test case hit this "size >= interval" issue when you ran your test?
Quoted 7 lines
Quoted 2 lines
None. I was just using the program to test some other stuff without any specific test.
Sure, good to know there's not other issues :) This program is a good tool to do some other tests, especially creates lots of data extents effectively :) I've pushed this patch to patches-in-queue branch, will merge it in next release after testing, feel free to check it.
Indeed, and took me a while to understand why I was ending up with an empty file instead of a bunch of extents :)
Quoted 19 lines
Thanks,
ZorroQuoted 13 lines
Quoted 12 lines
Reviewed-by Zorro Lang <[email protected]>Quoted 7 lines
src/punch-alternating.c +1
-0+if (optind != argc -1 )usage (argv[0 ]);Signature · 1 line
2.52.0