All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] common: switch _get_available_space accounting to units of 512 bytes
@ 2023-03-28 15:01 Anthony Iliopoulos
  2023-03-28 16:02 ` Darrick J. Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Iliopoulos @ 2023-03-28 15:01 UTC (permalink / raw)
  To: fstests

xfs/220 relies on detecting free space changes after truncation of
single filesystem blocks, and this fails when the fs block size is 512b.

By default df is counting 1024b block units and as such is not reporting
any change in the number of available blocks after freeing just a 512b
block.

Switch the df reporting block size from units of 1024b blocks to 512b
blocks to accommodate accounting for smaller granularity fs block sizes.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 90749343f3c4..a32bbe3c0b5f 100644
--- a/common/rc
+++ b/common/rc
@@ -4209,8 +4209,8 @@ _get_available_space()
 		exit 1
 	fi
 	local avail_kb;
-	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
-	echo $((avail_kb * 1024))
+	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
+	echo $((avail_kb * 512))
 }
 
 # get the total space in bytes
-- 
2.35.3


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

* Re: [PATCH] common: switch _get_available_space accounting to units of 512 bytes
  2023-03-28 15:01 [PATCH] common: switch _get_available_space accounting to units of 512 bytes Anthony Iliopoulos
@ 2023-03-28 16:02 ` Darrick J. Wong
  2023-03-28 18:03   ` Zorro Lang
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2023-03-28 16:02 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: fstests

On Tue, Mar 28, 2023 at 05:01:04PM +0200, Anthony Iliopoulos wrote:
> xfs/220 relies on detecting free space changes after truncation of
> single filesystem blocks, and this fails when the fs block size is 512b.
> 
> By default df is counting 1024b block units and as such is not reporting
> any change in the number of available blocks after freeing just a 512b
> block.
> 
> Switch the df reporting block size from units of 1024b blocks to 512b
> blocks to accommodate accounting for smaller granularity fs block sizes.
> 
> Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
> ---
>  common/rc | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 90749343f3c4..a32bbe3c0b5f 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4209,8 +4209,8 @@ _get_available_space()
>  		exit 1
>  	fi
>  	local avail_kb;
> -	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
> -	echo $((avail_kb * 1024))
> +	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
> +	echo $((avail_kb * 512))

Why not have df report the free space in bytes?

$DF_PROG -B 1 $1 | tail -n 1 | awk '{print $5}'

--D

>  }
>  
>  # get the total space in bytes
> -- 
> 2.35.3
> 

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

* Re: [PATCH] common: switch _get_available_space accounting to units of 512 bytes
  2023-03-28 16:02 ` Darrick J. Wong
@ 2023-03-28 18:03   ` Zorro Lang
  0 siblings, 0 replies; 3+ messages in thread
From: Zorro Lang @ 2023-03-28 18:03 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: fstests

On Tue, Mar 28, 2023 at 09:02:25AM -0700, Darrick J. Wong wrote:
> On Tue, Mar 28, 2023 at 05:01:04PM +0200, Anthony Iliopoulos wrote:
> > xfs/220 relies on detecting free space changes after truncation of
> > single filesystem blocks, and this fails when the fs block size is 512b.
> > 
> > By default df is counting 1024b block units and as such is not reporting
> > any change in the number of available blocks after freeing just a 512b
> > block.
> > 
> > Switch the df reporting block size from units of 1024b blocks to 512b
> > blocks to accommodate accounting for smaller granularity fs block sizes.
> > 
> > Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
> > ---
> >  common/rc | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/common/rc b/common/rc
> > index 90749343f3c4..a32bbe3c0b5f 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -4209,8 +4209,8 @@ _get_available_space()
> >  		exit 1
> >  	fi
> >  	local avail_kb;
> > -	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
> > -	echo $((avail_kb * 1024))
> > +	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
> > +	echo $((avail_kb * 512))
> 
> Why not have df report the free space in bytes?
> 
> $DF_PROG -B 1 $1 | tail -n 1 | awk '{print $5}'

Agree, if we finally hope to get "bytes", and we can get it at beginning, why
take a long way?

If you'd like to send a V2 to do that, you can do the same change on
_get_total_space() too.

Thanks,
Zorro

> 
> --D
> 
> >  }
> >  
> >  # get the total space in bytes
> > -- 
> > 2.35.3
> > 
> 


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

end of thread, other threads:[~2023-03-28 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 15:01 [PATCH] common: switch _get_available_space accounting to units of 512 bytes Anthony Iliopoulos
2023-03-28 16:02 ` Darrick J. Wong
2023-03-28 18:03   ` Zorro Lang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.