]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfs: Cancel dirty folios that have no storage destination
authorDavid Howells <dhowells@redhat.com>
Mon, 29 Jul 2024 11:23:11 +0000 (12:23 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 12 Sep 2024 10:20:41 +0000 (12:20 +0200)
Kafs wants to be able to cache the contents of directories (and symlinks),
but whilst these are downloaded from the server with the FS.FetchData RPC
op and similar, the same as for regular files, they can't be updated by
FS.StoreData, but rather have special operations (FS.MakeDir, etc.).

Now, rather than redownloading a directory's content after each change made
to that directory, kafs modifies the local blob.  This blob can be saved
out to the cache, and since it's using netfslib, kafs just marks the folios
dirty and lets ->writepages() on the directory take care of it, as for an
regular file.

This is fine as long as there's a cache as although the upload stream is
disabled, there's a cache stream to drive the procedure.  But if the cache
goes away in the meantime, suddenly there's no way do any writes and the
code gets confused, complains "R=%x: No submit" to dmesg and leaves the
dirty folio hanging.

Fix this by just cancelling the store of the folio if neither stream is
active.  (If there's no cache at the time of dirtying, we should just not
mark the folio dirty).

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20240814203850.2240469-23-dhowells@redhat.com/
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/write_issue.c
include/trace/events/netfs.h

index f7d59f0bb8c21b1db1614543dd0ec2ac079fc934..04e66d587f777cf8fec1b46ce58cf1dc49ea28b0 100644 (file)
@@ -400,13 +400,17 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
        folio_unlock(folio);
 
        if (fgroup == NETFS_FOLIO_COPY_TO_CACHE) {
-               if (!fscache_resources_valid(&wreq->cache_resources)) {
+               if (!cache->avail) {
                        trace_netfs_folio(folio, netfs_folio_trace_cancel_copy);
                        netfs_issue_write(wreq, upload);
                        netfs_folio_written_back(folio);
                        return 0;
                }
                trace_netfs_folio(folio, netfs_folio_trace_store_copy);
+       } else if (!upload->avail && !cache->avail) {
+               trace_netfs_folio(folio, netfs_folio_trace_cancel_store);
+               netfs_folio_written_back(folio);
+               return 0;
        } else if (!upload->construct) {
                trace_netfs_folio(folio, netfs_folio_trace_store);
        } else {
index 7b26463cb98ffbc20d822e6f936749a4f8f3fb65..76bd42a968155d0ad1fabcc0505319b0ffde5700 100644 (file)
        EM(netfs_streaming_cont_filled_page,    "mod-streamw-f+") \
        EM(netfs_folio_trace_abandon,           "abandon")      \
        EM(netfs_folio_trace_cancel_copy,       "cancel-copy")  \
+       EM(netfs_folio_trace_cancel_store,      "cancel-store") \
        EM(netfs_folio_trace_clear,             "clear")        \
        EM(netfs_folio_trace_clear_cc,          "clear-cc")     \
        EM(netfs_folio_trace_clear_g,           "clear-g")      \