From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH 1/3] filemap: Add a helper for filesystems implementing dropbehind
Date: Wed, 23 Apr 2025 00:25:30 -0400 [thread overview]
Message-ID: <5588a06f6d5a2cf6746828e2d36e7ada668b1739.1745381692.git.trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <cover.1745381692.git.trond.myklebust@hammerspace.com>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Add a helper to allow filesystems to attempt to free the 'dropbehind'
folio.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
include/linux/pagemap.h | 1 +
mm/filemap.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 26baa78f1ca7..63e2bee9f46b 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1225,6 +1225,7 @@ void folio_wait_writeback(struct folio *folio);
int folio_wait_writeback_killable(struct folio *folio);
void end_page_writeback(struct page *page);
void folio_end_writeback(struct folio *folio);
+void folio_end_dropbehind(struct folio *folio);
void folio_wait_stable(struct folio *folio);
void __folio_mark_dirty(struct folio *folio, struct address_space *, int warn);
void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb);
diff --git a/mm/filemap.c b/mm/filemap.c
index b5e784f34d98..12f694880bb8 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1589,6 +1589,22 @@ int folio_wait_private_2_killable(struct folio *folio)
}
EXPORT_SYMBOL(folio_wait_private_2_killable);
+/*
+ * Helper for filesystems that want to implement dropbehind, and that
+ * need to keep the folio around after folio_end_writeback, e.g. due to
+ * the need to first commit NFS stable writes.
+ */
+void folio_end_dropbehind(struct folio *folio)
+{
+ if (folio_trylock(folio)) {
+ if (folio->mapping && !folio_test_dirty(folio) &&
+ !folio_test_writeback(folio))
+ folio_unmap_invalidate(folio->mapping, folio, 0);
+ folio_unlock(folio);
+ }
+}
+EXPORT_SYMBOL(folio_end_dropbehind);
+
/*
* If folio was marked as dropbehind, then pages should be dropped when writeback
* completes. Do that now. If we fail, it's likely because of a big folio -
--
2.49.0
next prev parent reply other threads:[~2025-04-23 4:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 4:25 [RFC PATCH 0/3] Initial NFS client support for RWF_DONTCACHE trondmy
2025-04-23 4:25 ` trondmy [this message]
2025-04-24 21:30 ` [RFC PATCH 1/3] filemap: Add a helper for filesystems implementing dropbehind Mike Snitzer
2025-04-23 4:25 ` [RFC PATCH 2/3] filemap: Mark folios as dropbehind in generic_perform_write() trondmy
2025-04-24 21:30 ` Mike Snitzer
2025-04-23 4:25 ` [RFC PATCH 3/3] NFS: Enable the RWF_DONTCACHE flag for the NFS client trondmy
2025-04-24 21:31 ` Mike Snitzer
2025-04-23 14:38 ` [RFC PATCH 0/3] Initial NFS client support for RWF_DONTCACHE Chuck Lever
2025-04-23 15:22 ` Matthew Wilcox
2025-04-23 15:30 ` Chuck Lever
2025-04-24 16:51 ` Mike Snitzer
2025-04-24 16:59 ` Chuck Lever
2025-04-24 21:29 ` [PATCH 4/3] NFS: add RWF_DONTCACHE support to LOCALIO Mike Snitzer
2025-07-14 6:22 ` [RFC PATCH 0/3] Initial NFS client support for RWF_DONTCACHE Christoph Hellwig
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=5588a06f6d5a2cf6746828e2d36e7ada668b1739.1745381692.git.trond.myklebust@hammerspace.com \
--to=trondmy@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@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