linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <brauner@kernel.org>,
	Carlos Maiolino <cem@kernel.org>, Qu Wenruo <wqu@suse.com>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 4/4] xfs: support sub-block aligned vectors in always COW mode
Date: Mon, 27 Oct 2025 09:15:11 -0700	[thread overview]
Message-ID: <20251027161511.GV3356773@frogsfrogsfrogs> (raw)
In-Reply-To: <20251023135559.124072-5-hch@lst.de>

On Thu, Oct 23, 2025 at 03:55:45PM +0200, Christoph Hellwig wrote:
> Now that the block layer and iomap have grown support to indicate
> the bio sector size explicitly instead of assuming the device sector
> size, we can ask for logical block size alignment and thus support
> direct I/O writes where the overall size is logical block size
> aligned, but the boundaries between vectors might not be.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_file.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 2702fef2c90c..f2ac4115c18b 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -674,8 +674,17 @@ xfs_file_dio_write_aligned(
>  	struct xfs_zone_alloc_ctx *ac)
>  {
>  	unsigned int		iolock = XFS_IOLOCK_SHARED;
> +	unsigned int		dio_flags = 0;
>  	ssize_t			ret;
>  
> +	/*
> +	 * For always COW inodes, each bio must be aligned to the file system
> +	 * block size and not just the device sector size because we need to
> +	 * allocate a block-aligned amount of space for each write.
> +	 */
> +	if (xfs_is_always_cow_inode(ip))
> +		dio_flags |= IOMAP_DIO_FSBLOCK_ALIGNED;
> +
>  	ret = xfs_ilock_iocb_for_write(iocb, &iolock);
>  	if (ret)
>  		return ret;
> @@ -693,7 +702,7 @@ xfs_file_dio_write_aligned(
>  		iolock = XFS_IOLOCK_SHARED;
>  	}
>  	trace_xfs_file_direct_write(iocb, from);
> -	ret = iomap_dio_rw(iocb, from, ops, dops, 0, ac, 0);
> +	ret = iomap_dio_rw(iocb, from, ops, dops, dio_flags, ac, 0);
>  out_unlock:
>  	xfs_iunlock(ip, iolock);
>  	return ret;
> @@ -890,15 +899,7 @@ xfs_file_dio_write(
>  	if ((iocb->ki_pos | count) & target->bt_logical_sectormask)
>  		return -EINVAL;
>  
> -	/*
> -	 * For always COW inodes we also must check the alignment of each
> -	 * individual iovec segment, as they could end up with different
> -	 * I/Os due to the way bio_iov_iter_get_pages works, and we'd
> -	 * then overwrite an already written block.
> -	 */
> -	if (((iocb->ki_pos | count) & ip->i_mount->m_blockmask) ||
> -	    (xfs_is_always_cow_inode(ip) &&
> -	     (iov_iter_alignment(from) & ip->i_mount->m_blockmask)))
> +	if ((iocb->ki_pos | count) & ip->i_mount->m_blockmask)
>  		return xfs_file_dio_write_unaligned(ip, iocb, from);
>  	if (xfs_is_zoned_inode(ip))
>  		return xfs_file_dio_write_zoned(ip, iocb, from);
> -- 
> 2.47.3
> 
> 

      reply	other threads:[~2025-10-27 16:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 13:55 alloc misaligned vectors for zoned XFS Christoph Hellwig
2025-10-23 13:55 ` [PATCH 1/4] iomap: add IOMAP_DIO_FSBLOCK_ALIGNED flag Christoph Hellwig
2025-10-27 16:10   ` Darrick J. Wong
2025-10-27 21:41     ` Qu Wenruo
2025-10-27 21:56       ` Darrick J. Wong
2025-10-29  7:44       ` Christoph Hellwig
2025-10-29  8:00         ` Qu Wenruo
2025-10-29  8:15           ` Christoph Hellwig
2025-10-31 12:40             ` Christian Brauner
2025-10-23 13:55 ` [PATCH 2/4] FIXUP: iomap: aligning to larger than fs block size doesn't make sense Christoph Hellwig
2025-10-27 16:11   ` Darrick J. Wong
2025-10-23 13:55 ` [PATCH 3/4] FIXUP: iomap: also apply IOMAP_DIO_FSBLOCK_ALIGNED to the iomap range Christoph Hellwig
2025-10-27 16:12   ` Darrick J. Wong
2025-10-23 13:55 ` [PATCH 4/4] xfs: support sub-block aligned vectors in always COW mode Christoph Hellwig
2025-10-27 16:15   ` 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=20251027161511.GV3356773@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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).