FS/XFS testing framework
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Anthony Iliopoulos <ailiop@suse.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes
Date: Wed, 29 Mar 2023 09:52:53 -0700	[thread overview]
Message-ID: <20230329165253.GC16170@frogsfrogsfrogs> (raw)
In-Reply-To: <20230329155236.81521-1-ailiop@suse.com>

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
> 

      reply	other threads:[~2023-03-29 16:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230329165253.GC16170@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=ailiop@suse.com \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox