From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Chandan Babu R <chandan.babu@oracle.com>,
Christian Brauner <brauner@kernel.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 02/10] iomap: improve shared block detection in iomap_unshare_iter
Date: Mon, 26 Aug 2024 22:44:24 -0700 [thread overview]
Message-ID: <20240827054424.GM6043@frogsfrogsfrogs> (raw)
In-Reply-To: <20240827051028.1751933-3-hch@lst.de>
On Tue, Aug 27, 2024 at 07:09:49AM +0200, Christoph Hellwig wrote:
> Currently iomap_unshare_iter relies on the IOMAP_F_SHARED flag to detect
> blocks to unshare. This is reasonable, but IOMAP_F_SHARED is also useful
> for the file system to do internal book keeping for out of place writes.
> XFS used to that, until it got removed in commit 72a048c1056a
> ("xfs: only set IOMAP_F_SHARED when providing a srcmap to a write")
> because unshare for incorrectly unshare such blocks.
>
> Add an extra safeguard by checking the explicitly provided srcmap instead
> of the fallback to the iomap for valid data, as that catches the case
> where we'd just copy from the same place we'd write to easily, allowing
> to reinstate setting IOMAP_F_SHARED for all XFS writes that go to the
> COW fork.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/iomap/buffered-io.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 69a931de1979b9..737a005082e035 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1337,16 +1337,25 @@ EXPORT_SYMBOL_GPL(iomap_file_buffered_write_punch_delalloc);
> static loff_t iomap_unshare_iter(struct iomap_iter *iter)
> {
> struct iomap *iomap = &iter->iomap;
> - const struct iomap *srcmap = iomap_iter_srcmap(iter);
> loff_t pos = iter->pos;
> loff_t length = iomap_length(iter);
> loff_t written = 0;
>
> - /* don't bother with blocks that are not shared to start with */
> + /* Don't bother with blocks that are not shared to start with. */
> if (!(iomap->flags & IOMAP_F_SHARED))
> return length;
> - /* don't bother with holes or unwritten extents */
> - if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN)
> +
> + /*
> + * Don't bother with holes or unwritten extents.
> + *
> + * Note that we use srcmap directly instead of iomap_iter_srcmap as
> + * unsharing requires providing a separate source map, and the presence
> + * of one is a good indicator that unsharing is needed, unlike
> + * IOMAP_F_SHARED which can be set for any data that goes into the COW
Maybe we should rename it then?
IOMAP_F_OUT_OF_PLACE_WRITE.
Yuck.
IOMAP_F_ELSEWHERE
Not much better. Maybe just add a comment that "IOMAP_F_SHARED" really
just means an out of place write (aka srcmap is not just a hole).
--D
> + * fork for XFS.
> + */
> + if (iter->srcmap.type == IOMAP_HOLE ||
> + iter->srcmap.type == IOMAP_UNWRITTEN)
> return length;
>
> do {
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2024-08-27 5:44 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 5:09 fix stale delalloc punching for COW I/O Christoph Hellwig
2024-08-27 5:09 ` [PATCH 01/10] iomap: handle a post-direct I/O invalidate race in iomap_write_delalloc_release Christoph Hellwig
2024-08-27 16:14 ` Darrick J. Wong
2024-08-28 4:48 ` Christoph Hellwig
2024-08-28 16:13 ` Darrick J. Wong
2024-08-29 3:46 ` Christoph Hellwig
2024-08-29 14:22 ` Darrick J. Wong
2024-08-30 3:42 ` Christoph Hellwig
2024-08-27 5:09 ` [PATCH 02/10] iomap: improve shared block detection in iomap_unshare_iter Christoph Hellwig
2024-08-27 5:44 ` Darrick J. Wong [this message]
2024-08-27 5:47 ` Christoph Hellwig
2024-08-27 16:21 ` Darrick J. Wong
2024-08-28 4:49 ` Christoph Hellwig
2024-08-28 16:17 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 03/10] iomap: pass flags to iomap_file_buffered_write_punch_delalloc Christoph Hellwig
2024-08-27 16:22 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 04/10] iomap: zeroing already holds invalidate_lock in iomap_file_buffered_write_punch_delalloc Christoph Hellwig
2024-08-27 16:28 ` Darrick J. Wong
2024-08-28 4:51 ` Christoph Hellwig
2024-08-27 5:09 ` [PATCH 05/10] iomap: pass the iomap to the punch callback Christoph Hellwig
2024-08-27 16:28 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 06/10] iomap: remove the iomap_file_buffered_write_punch_delalloc return value Christoph Hellwig
2024-08-27 16:36 ` Darrick J. Wong
2024-08-28 4:52 ` Christoph Hellwig
2024-08-28 16:18 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 07/10] xfs: support the COW fork in xfs_bmap_punch_delalloc_range Christoph Hellwig
2024-08-27 16:37 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 08/10] xfs: share a bit more code in xfs_buffered_write_iomap_begin Christoph Hellwig
2024-08-27 16:38 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 09/10] xfs: set IOMAP_F_SHARED for all COW fork allocations Christoph Hellwig
2024-08-27 16:44 ` Darrick J. Wong
2024-08-27 5:09 ` [PATCH 10/10] xfs: punch delalloc extents from the COW fork for COW writes Christoph Hellwig
2024-08-27 16:44 ` 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=20240827054424.GM6043@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=brauner@kernel.org \
--cc=chandan.babu@oracle.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@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