Patch "iomap: improve shared block detection in iomap_unshare_iter" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iomap: improve shared block detection in iomap_unshare_iter

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iomap-improve-shared-block-detection-in-iomap_unshar.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e960ddf9a5870e1e981815fdccc4ca825e72a367
Author: Christoph Hellwig <hch@xxxxxx>
Date:   Tue Sep 10 07:39:04 2024 +0300

    iomap: improve shared block detection in iomap_unshare_iter
    
    [ Upstream commit b53fdb215d13f8e9c29541434bf2d14dac8bcbdc ]
    
    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@xxxxxx>
    Link: https://lore.kernel.org/r/20240910043949.3481298-3-hch@xxxxxx
    Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Stable-dep-of: 50793801fc7f ("fsdax: dax_unshare_iter needs to copy entire blocks")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 674ac79bdb456..527d3bcfc69a7 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1087,16 +1087,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
+	 * fork for XFS.
+	 */
+	if (iter->srcmap.type == IOMAP_HOLE ||
+	    iter->srcmap.type == IOMAP_UNWRITTEN)
 		return length;
 
 	do {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux