From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH 3/3] NFS: Enable the RWF_DONTCACHE flag for the NFS client
Date: Wed, 23 Apr 2025 00:25:32 -0400 [thread overview]
Message-ID: <ec165b304a7b56d1fa4c6c2b1ad1c04d4dcbd3f6.1745381692.git.trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <cover.1745381692.git.trond.myklebust@hammerspace.com>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
While the NFS readahead code has no problems using the generic code to
manage the dropbehind behaviour enabled by RWF_DONTCACHE, the write code
needs to deal with the fact that NFS writeback uses a 2 step process
(UNSTABLE write followed by COMMIT).
This commit replaces the use of the folio dropbehind flag with a local
NFS request flag that triggers the dropbehind behaviour once the data
has been written to stable storage.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/file.c | 2 ++
fs/nfs/nfs4file.c | 2 ++
fs/nfs/write.c | 12 +++++++++++-
include/linux/nfs_page.h | 1 +
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 033feeab8c34..60d47f141acb 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -910,5 +910,7 @@ const struct file_operations nfs_file_operations = {
.splice_write = iter_file_splice_write,
.check_flags = nfs_check_flags,
.setlease = simple_nosetlease,
+
+ .fop_flags = FOP_DONTCACHE,
};
EXPORT_SYMBOL_GPL(nfs_file_operations);
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 1cd9652f3c28..e6726499c585 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -467,4 +467,6 @@ const struct file_operations nfs4_file_operations = {
#else
.llseek = nfs_file_llseek,
#endif
+
+ .fop_flags = FOP_DONTCACHE,
};
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 23df8b214474..e0ac439ab211 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -359,8 +359,12 @@ static void nfs_folio_end_writeback(struct folio *folio)
static void nfs_page_end_writeback(struct nfs_page *req)
{
if (nfs_page_group_sync_on_bit(req, PG_WB_END)) {
+ struct folio *folio = nfs_page_to_folio(req);
+
+ if (folio_test_clear_dropbehind(folio))
+ set_bit(PG_DROPBEHIND, &req->wb_flags);
nfs_unlock_request(req);
- nfs_folio_end_writeback(nfs_page_to_folio(req));
+ nfs_folio_end_writeback(folio);
} else
nfs_unlock_request(req);
}
@@ -813,6 +817,9 @@ static void nfs_inode_remove_request(struct nfs_page *req)
clear_bit(PG_MAPPED, &req->wb_head->wb_flags);
}
spin_unlock(&mapping->i_private_lock);
+
+ if (test_bit(PG_DROPBEHIND, &req->wb_flags))
+ folio_end_dropbehind(folio);
}
if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) {
@@ -2093,6 +2100,7 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio)
.range_start = range_start,
.range_end = range_start + len - 1,
};
+ bool dropbehind = folio_test_clear_dropbehind(folio);
int ret;
trace_nfs_writeback_folio(inode, range_start, len);
@@ -2113,6 +2121,8 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio)
goto out_error;
}
out_error:
+ if (dropbehind)
+ folio_set_dropbehind(folio);
trace_nfs_writeback_folio_done(inode, range_start, len, ret);
return ret;
}
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 169b4ae30ff4..1a017b5b476f 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -37,6 +37,7 @@ enum {
PG_REMOVE, /* page group sync bit in write path */
PG_CONTENDED1, /* Is someone waiting for a lock? */
PG_CONTENDED2, /* Is someone waiting for a lock? */
+ PG_DROPBEHIND, /* Implement RWF_DONTCACHE */
};
struct nfs_inode;
--
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 ` [RFC PATCH 1/3] filemap: Add a helper for filesystems implementing dropbehind trondmy
2025-04-24 21:30 ` 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 ` trondmy [this message]
2025-04-24 21:31 ` [RFC PATCH 3/3] NFS: Enable the RWF_DONTCACHE flag for the NFS client 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=ec165b304a7b56d1fa4c6c2b1ad1c04d4dcbd3f6.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