public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] punch-alternating: prevent punching all extents
@ 2025-12-21 10:24 cem
  2025-12-31 18:46 ` Zorro Lang
  0 siblings, 1 reply; 5+ messages in thread
From: cem @ 2025-12-21 10:24 UTC (permalink / raw)
  To: zlang; +Cc: linux-xfs, djwong, fstests

From: Carlos Maiolino <cem@kernel.org>

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 <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
 src/punch-alternating.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index d2bb4b6a2276..c555b48d8591 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -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]);
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] punch-alternating: prevent punching all extents
  2025-12-21 10:24 [PATCH] punch-alternating: prevent punching all extents cem
@ 2025-12-31 18:46 ` Zorro Lang
  2026-01-02 13:36   ` Carlos Maiolino
  0 siblings, 1 reply; 5+ messages in thread
From: Zorro Lang @ 2025-12-31 18:46 UTC (permalink / raw)
  To: cem; +Cc: zlang, linux-xfs, djwong, fstests

On Sun, Dec 21, 2025 at 11:24:50AM +0100, cem@kernel.org wrote:
> From: Carlos Maiolino <cem@kernel.org>
> 
> 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 <cmaiolino@redhat.com>
> Signed-off-by: Carlos Maiolino <cem@kernel.org>
> ---
>  src/punch-alternating.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> index d2bb4b6a2276..c555b48d8591 100644
> --- a/src/punch-alternating.c
> +++ b/src/punch-alternating.c
> @@ -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?

Reviewed-by: Zorro Lang <zlang@redhat.com>

> +
>  	if (optind != argc - 1)
>  		usage(argv[0]);
>  
> -- 
> 2.52.0
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] punch-alternating: prevent punching all extents
  2025-12-31 18:46 ` Zorro Lang
@ 2026-01-02 13:36   ` Carlos Maiolino
  2026-01-02 15:43     ` Zorro Lang
  0 siblings, 1 reply; 5+ messages in thread
From: Carlos Maiolino @ 2026-01-02 13:36 UTC (permalink / raw)
  To: Zorro Lang; +Cc: zlang, linux-xfs, djwong, fstests

On Thu, Jan 01, 2026 at 02:46:18AM +0800, Zorro Lang wrote:
> On Sun, Dec 21, 2025 at 11:24:50AM +0100, cem@kernel.org wrote:
> > From: Carlos Maiolino <cem@kernel.org>
> > 
> > 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 <cmaiolino@redhat.com>
> > Signed-off-by: Carlos Maiolino <cem@kernel.org>
> > ---
> >  src/punch-alternating.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> > index d2bb4b6a2276..c555b48d8591 100644
> > --- a/src/punch-alternating.c
> > +++ b/src/punch-alternating.c
> > @@ -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?

None. I was just using the program to test some other stuff without any
specific test.

> 
> Reviewed-by: Zorro Lang <zlang@redhat.com>
> 
> > +
> >  	if (optind != argc - 1)
> >  		usage(argv[0]);
> >  
> > -- 
> > 2.52.0
> > 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] punch-alternating: prevent punching all extents
  2026-01-02 13:36   ` Carlos Maiolino
@ 2026-01-02 15:43     ` Zorro Lang
  2026-01-05  9:51       ` Carlos Maiolino
  0 siblings, 1 reply; 5+ messages in thread
From: Zorro Lang @ 2026-01-02 15:43 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: zlang, linux-xfs, djwong, fstests

On Fri, Jan 02, 2026 at 02:36:01PM +0100, Carlos Maiolino wrote:
> On Thu, Jan 01, 2026 at 02:46:18AM +0800, Zorro Lang wrote:
> > On Sun, Dec 21, 2025 at 11:24:50AM +0100, cem@kernel.org wrote:
> > > From: Carlos Maiolino <cem@kernel.org>
> > > 
> > > 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 <cmaiolino@redhat.com>
> > > Signed-off-by: Carlos Maiolino <cem@kernel.org>
> > > ---
> > >  src/punch-alternating.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> > > index d2bb4b6a2276..c555b48d8591 100644
> > > --- a/src/punch-alternating.c
> > > +++ b/src/punch-alternating.c
> > > @@ -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?
> 
> 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

> 
> > 
> > Reviewed-by: Zorro Lang <zlang@redhat.com>
> > 
> > > +
> > >  	if (optind != argc - 1)
> > >  		usage(argv[0]);
> > >  
> > > -- 
> > > 2.52.0
> > > 
> > 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] punch-alternating: prevent punching all extents
  2026-01-02 15:43     ` Zorro Lang
@ 2026-01-05  9:51       ` Carlos Maiolino
  0 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2026-01-05  9:51 UTC (permalink / raw)
  To: Zorro Lang; +Cc: zlang, linux-xfs, djwong, fstests

On Fri, Jan 02, 2026 at 11:43:15PM +0800, Zorro Lang wrote:
> On Fri, Jan 02, 2026 at 02:36:01PM +0100, Carlos Maiolino wrote:
> > On Thu, Jan 01, 2026 at 02:46:18AM +0800, Zorro Lang wrote:
> > > On Sun, Dec 21, 2025 at 11:24:50AM +0100, cem@kernel.org wrote:
> > > > From: Carlos Maiolino <cem@kernel.org>
> > > > 
> > > > 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 <cmaiolino@redhat.com>
> > > > Signed-off-by: Carlos Maiolino <cem@kernel.org>
> > > > ---
> > > >  src/punch-alternating.c | 5 +++++
> > > >  1 file changed, 5 insertions(+)
> > > > 
> > > > diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> > > > index d2bb4b6a2276..c555b48d8591 100644
> > > > --- a/src/punch-alternating.c
> > > > +++ b/src/punch-alternating.c
> > > > @@ -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?
> > 
> > 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 :)


> 
> Thanks,
> Zorro
> 
> > 
> > > 
> > > Reviewed-by: Zorro Lang <zlang@redhat.com>
> > > 
> > > > +
> > > >  	if (optind != argc - 1)
> > > >  		usage(argv[0]);
> > > >  
> > > > -- 
> > > > 2.52.0
> > > > 
> > > 
> > 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-05  9:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-21 10:24 [PATCH] punch-alternating: prevent punching all extents cem
2025-12-31 18:46 ` Zorro Lang
2026-01-02 13:36   ` Carlos Maiolino
2026-01-02 15:43     ` Zorro Lang
2026-01-05  9:51       ` Carlos Maiolino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox