Patch "netfs: Fix writeback that needs to go to both server and cache" has been added to the 6.10-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

    netfs: Fix writeback that needs to go to both server and cache

to the 6.10-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:
     netfs-fix-writeback-that-needs-to-go-to-both-server-.patch
and it can be found in the queue-6.10 subdirectory.

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



commit 05cab711b96a0a9d99c98a9d0280901f4bbe4a60
Author: David Howells <dhowells@xxxxxxxxxx>
Date:   Fri Jul 19 15:20:18 2024 +0100

    netfs: Fix writeback that needs to go to both server and cache
    
    [ Upstream commit 212be98aa19303cbf376d61faf9de3ec9997c1cd ]
    
    When netfslib is performing writeback (ie. ->writepages), it maintains two
    parallel streams of writes, one to the server and one to the cache, but it
    doesn't mark either stream of writes as active until it gets some data that
    needs to be written to that stream.
    
    This is done because some folios will only be written to the cache
    (e.g. copying to the cache on read is done by marking the folios and
    letting writeback do the actual work) and sometimes we'll only be writing
    to the server (e.g. if there's no cache).
    
    Now, since we don't actually dispatch uploads and cache writes in parallel,
    but rather flip between the streams, depending on which has the lowest
    so-far-issued offset, and don't wait for the subreqs to finish before
    flipping, we can end up in a situation where, say, we issue a write to the
    server and this completes before we start the write to the cache.
    
    But because we only activate a stream when we first add a subreq to it, the
    result collection code may run before we manage to activate the stream -
    resulting in the folio being cleaned and having the writeback-in-progress
    mark removed.  At this point, the folio no longer belongs to us.
    
    This is only really a problem for folios that need to be written to both
    streams - and in that case, the upload to the server is started first,
    followed by the write to the cache - and the cache write may see a bad
    folio.
    
    Fix this by activating the cache stream up front if there's a cache
    available.  If there's a cache, then all data is going to be written to it.
    
    Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
    Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/1599053.1721398818@xxxxxxxxxxxxxxxxxxxxxx
    cc: Jeff Layton <jlayton@xxxxxxxxxx>
    cc: netfs@xxxxxxxxxxxxxxx
    cc: linux-fsdevel@xxxxxxxxxxxxxxx
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
index d7c971df88660..32bc88bee5d18 100644
--- a/fs/netfs/write_issue.c
+++ b/fs/netfs/write_issue.c
@@ -122,6 +122,7 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping,
 	wreq->io_streams[1].transferred		= LONG_MAX;
 	if (fscache_resources_valid(&wreq->cache_resources)) {
 		wreq->io_streams[1].avail	= true;
+		wreq->io_streams[1].active	= true;
 		wreq->io_streams[1].prepare_write = wreq->cache_resources.ops->prepare_write_subreq;
 		wreq->io_streams[1].issue_write = wreq->cache_resources.ops->issue_write;
 	}




[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