public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Chandan Babu R <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Hongbo Li <lihongbo22@huawei.com>,
	Ryusuke Konishi <konishi.ryusuke@gmail.com>,
	linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/5] xfs: report the correct read/write dio alignment for reflinked inodes
Date: Wed, 8 Jan 2025 09:53:58 -0800	[thread overview]
Message-ID: <20250108175358.GA29347@sol.localdomain> (raw)
In-Reply-To: <20250108085549.1296733-5-hch@lst.de>

On Wed, Jan 08, 2025 at 09:55:32AM +0100, Christoph Hellwig wrote:
> For I/O to reflinked blocks we always need to write an entire new
> file system block, and the code enforces the file system block alignment
> for the entire file if it has any reflinked blocks.
> 
> Use the new STATX_DIO_READ_ALIGN flag to report the asymmetric read
> vs write alignments for reflinked files.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
>  fs/xfs/xfs_iops.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 6b0228a21617..40289fe6f5b2 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -580,9 +580,24 @@ xfs_report_dioalign(
>  	struct xfs_buftarg	*target = xfs_inode_buftarg(ip);
>  	struct block_device	*bdev = target->bt_bdev;
>  
> -	stat->result_mask |= STATX_DIOALIGN;
> +	stat->result_mask |= STATX_DIOALIGN | STATX_DIO_READ_ALIGN;
>  	stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
> -	stat->dio_offset_align = bdev_logical_block_size(bdev);
> +
> +	/*
> +	 * For COW inodes, we can only perform out of place writes of entire
> +	 * allocation units (blocks or RT extents).
> +	 * For writes smaller than the allocation unit, we must fall back to
> +	 * buffered I/O to perform read-modify-write cycles.  At best this is
> +	 * highly inefficient; at worst it leads to page cache invalidation
> +	 * races.  Tell applications to avoid this by reporting the larger write
> +	 * alignment in dio_offset_align, and the smaller read alignment in
> +	 * dio_read_offset_align.
> +	 */
> +	stat->dio_read_offset_align = bdev_logical_block_size(bdev);
> +	if (xfs_is_cow_inode(ip))
> +		stat->dio_offset_align = xfs_inode_alloc_unitsize(ip);
> +	else
> +		stat->dio_offset_align = stat->dio_read_offset_align;

This contradicts the proposed man page, which says the following about
stx_dio_read_offset_align offset:

          If non-zero this value must be smaller than  stx_dio_offset_align
          which  must be provided by the file system.

The proposed code sets stx_dio_read_offset_align and stx_dio_offset_align to the
same value in some cases.

Perhaps the documentation should say "less than or equal to"?

Also, the claim that stx_dio_offset_align "must be provided by the file system"
if stx_dio_read_offset_align is nonzero should probably be conditional on
STATX_DIOALIGN being provided too.

- Eric

  parent reply	other threads:[~2025-01-08 17:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08  8:55 add STATX_DIO_READ_ALIGN v2 Christoph Hellwig
2025-01-08  8:55 ` [PATCH 1/5] fs: reformat the statx definition Christoph Hellwig
2025-01-08 10:08   ` John Garry
2025-01-08  8:55 ` [PATCH 2/5] fs: add STATX_DIO_READ_ALIGN Christoph Hellwig
2025-01-08 10:09   ` John Garry
2025-01-08  8:55 ` [PATCH 3/5] xfs: cleanup xfs_vn_getattr Christoph Hellwig
2025-01-08  8:55 ` [PATCH 4/5] xfs: report the correct read/write dio alignment for reflinked inodes Christoph Hellwig
2025-01-08 10:10   ` John Garry
2025-01-08 10:13   ` John Garry
2025-01-08 15:18     ` Christoph Hellwig
2025-01-08 17:20       ` Darrick J. Wong
2025-01-08 17:53   ` Eric Biggers [this message]
2025-01-09  6:25     ` Christoph Hellwig
2025-01-08  8:55 ` [PATCH 5/5] xfs: report larger dio alignment for COW inodes Christoph Hellwig
2025-01-08 10:11   ` John Garry
2025-01-08 17:25     ` Darrick J. Wong
2025-01-08  8:59 ` [PATCH] statx.2: document STATX_DIO_READ_ALIGN Christoph Hellwig
2025-01-08 17:27   ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2025-01-09  8:31 add STATX_DIO_READ_ALIGN v3 Christoph Hellwig
2025-01-09  8:31 ` [PATCH 4/5] xfs: report the correct read/write dio alignment for reflinked inodes Christoph Hellwig

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=20250108175358.GA29347@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=brauner@kernel.org \
    --cc=chandan.babu@oracle.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=konishi.ryusuke@gmail.com \
    --cc=lihongbo22@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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