fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: guaneryu@gmail.com, linux-xfs@vger.kernel.org,
	fstests@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/9] common: extract rt extent size for _get_file_block_size
Date: Wed, 28 Oct 2020 07:41:19 +0000	[thread overview]
Message-ID: <20201028074119.GA2750@infradead.org> (raw)
In-Reply-To: <160382529579.1202316.931742119756545034.stgit@magnolia>

On Tue, Oct 27, 2020 at 12:01:35PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> _get_file_block_size is intended to return the size (in bytes) of the
> fundamental allocation unit for a file.  This is required for remapping
> operations like fallocate and reflink, which can only operate on
> allocation units.  Since the XFS realtime volume can be configure for
> allocation units larger than 1 fs block, we need to factor that in here.

Should this also cover the ext4 bigalloc clusters?  Or do they not
matter for fallocate?

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc  |   13 ++++++++++---
>  common/xfs |   20 ++++++++++++++++++++
>  2 files changed, 30 insertions(+), 3 deletions(-)
> 
> 
> diff --git a/common/rc b/common/rc
> index 27a27ea3..41f93047 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -3974,11 +3974,18 @@ _get_file_block_size()
>  		echo "Missing mount point argument for _get_file_block_size"
>  		exit 1
>  	fi
> -	if [ "$FSTYP" = "ocfs2" ]; then
> +
> +	case "$FSTYP" in
> +	"ocfs2")
>  		stat -c '%o' $1
> -	else
> +		;;
> +	"xfs")
> +		_xfs_get_file_block_size $1
> +		;;
> +	*)
>  		_get_block_size $1
> -	fi
> +		;;
> +	esac
>  }
>  
>  # Get the minimum block size of an fs.
> diff --git a/common/xfs b/common/xfs
> index 79dab058..3f5c14ba 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -174,6 +174,26 @@ _scratch_mkfs_xfs()
>  	return $mkfs_status
>  }
>  
> +# Get the size of an allocation unit of a file.  Normally this is just the
> +# block size of the file, but for realtime files, this is the realtime extent
> +# size.
> +_xfs_get_file_block_size()
> +{
> +	local path="$1"
> +
> +	if ! ($XFS_IO_PROG -c "stat -v" "$path" 2>&1 | egrep -q '(rt-inherit|realtime)'); then
> +		_get_block_size "$path"
> +		return
> +	fi
> +
> +	# Otherwise, call xfs_info until we find a mount point or the root.
> +	path="$(readlink -m "$path")"
> +	while ! $XFS_INFO_PROG "$path" &>/dev/null && [ "$path" != "/" ]; do
> +		path="$(dirname "$path")"
> +	done
> +	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
> +}
> +
>  # xfs_check script is planned to be deprecated. But, we want to
>  # be able to invoke "xfs_check" behavior in xfstests in order to
>  # maintain the current verification levels.
> 
---end quoted text---

  reply	other threads:[~2020-10-28 21:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 19:01 [PATCH 0/9] xfstests: random fixes Darrick J. Wong
2020-10-27 19:01 ` [PATCH 1/9] common: extract rt extent size for _get_file_block_size Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig [this message]
2020-10-28 22:24     ` Darrick J. Wong
2020-10-27 19:01 ` [PATCH 2/9] xfs/520: disable external devices Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig
2020-10-27 19:01 ` [PATCH 3/9] xfs/341: fix test when rextsize > 1 Darrick J. Wong
2020-10-28  7:41   ` Christoph Hellwig
2020-10-27 19:01 ` [PATCH 4/9] various: replace _get_block_size with _get_file_block_size when needed Darrick J. Wong
2020-10-28  7:42   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 5/9] xfs/327: fix inode reflink flag checking Darrick J. Wong
2020-10-28  7:42   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 6/9] xfs/27[26]: force realtime on or off as needed Darrick J. Wong
2020-10-28  7:43   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 7/9] xfs/030: hide the btree levels check errors Darrick J. Wong
2020-10-28  7:43   ` Christoph Hellwig
2020-10-27 19:02 ` [PATCH 8/9] check: run tests in a systemd scope for mandatory test cleanup Darrick J. Wong
2020-10-28  7:44   ` Christoph Hellwig
2020-10-28 16:58     ` Darrick J. Wong
2020-10-29  1:04     ` Darrick J. Wong
2020-11-02 21:37   ` Darrick J. Wong
2020-10-27 19:02 ` [PATCH 9/9] common/populate: make sure _scratch_xfs_populate puts its files on the data device Darrick J. Wong
2020-10-28  7:44   ` Christoph Hellwig
2020-10-28 16:27     ` Darrick J. Wong
2020-11-08 10:05 ` [PATCH 0/9] xfstests: random fixes Eryu Guan
2020-11-08 17:23   ` Darrick J. Wong

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=20201028074119.GA2750@infradead.org \
    --to=hch@infradead.org \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).