* [PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes
@ 2023-03-29 15:52 Anthony Iliopoulos
2023-03-29 16:52 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Iliopoulos @ 2023-03-29 15:52 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 _get_available_space df reporting block size from units of
1024b blocks directly to single bytes in order to make free space
accounting fine-grained and independent of any fs block size
assumptions.
Do the same for _get_available_space, since there is no reason for
having an additional conversion step.
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
common/rc | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
v2: incorporate changes from reviews by djwong and zlang
* change reporting directly to bytes and avoid conversion step
altogether
* do the same for _get_available_space
diff --git a/common/rc b/common/rc
index 90749343f3c4..9e4475c0f429 100644
--- a/common/rc
+++ b/common/rc
@@ -4208,9 +4208,7 @@ _get_available_space()
echo "Usage: _get_available_space <mnt>"
exit 1
fi
- local avail_kb;
- avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
- echo $((avail_kb * 1024))
+ $DF_PROG -B 1 $1 | tail -n1 | awk '{ print $5 }'
}
# get the total space in bytes
@@ -4221,9 +4219,7 @@ _get_total_space()
echo "Usage: _get_total_space <mnt>"
exit 1
fi
- local total_kb;
- total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'`
- echo $(($total_kb * 1024))
+ $DF_PROG -B 1 $1 | tail -n1 | awk '{ print $3 }'
}
# return device size in kb
--
2.35.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes
2023-03-29 15:52 [PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes Anthony Iliopoulos
@ 2023-03-29 16:52 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2023-03-29 16:52 UTC (permalink / raw)
To: Anthony Iliopoulos; +Cc: fstests
On Wed, Mar 29, 2023 at 05:52:36PM +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 _get_available_space df reporting block size from units of
> 1024b blocks directly to single bytes in order to make free space
> accounting fine-grained and independent of any fs block size
> assumptions.
>
> Do the same for _get_available_space, since there is no reason for
> having an additional conversion step.
>
> Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
> ---
> common/rc | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> v2: incorporate changes from reviews by djwong and zlang
> * change reporting directly to bytes and avoid conversion step
> altogether
> * do the same for _get_available_space
>
> diff --git a/common/rc b/common/rc
> index 90749343f3c4..9e4475c0f429 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4208,9 +4208,7 @@ _get_available_space()
> echo "Usage: _get_available_space <mnt>"
> exit 1
> fi
> - local avail_kb;
> - avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
> - echo $((avail_kb * 1024))
> + $DF_PROG -B 1 $1 | tail -n1 | awk '{ print $5 }'
> }
>
> # get the total space in bytes
> @@ -4221,9 +4219,7 @@ _get_total_space()
> echo "Usage: _get_total_space <mnt>"
> exit 1
> fi
> - local total_kb;
> - total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'`
> - echo $(($total_kb * 1024))
> + $DF_PROG -B 1 $1 | tail -n1 | awk '{ print $3 }'
Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> }
>
> # return device size in kb
> --
> 2.35.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-29 16:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 15:52 [PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes Anthony Iliopoulos
2023-03-29 16:52 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox