From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Christian Brauner <brauner@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH 3/3] fs: Pass a folio to page_put_link()
Date: Wed, 14 May 2025 18:13:14 +0100 [thread overview]
Message-ID: <20250514171316.3002934-4-willy@infradead.org> (raw)
In-Reply-To: <20250514171316.3002934-1-willy@infradead.org>
All callers now have a folio. Pass it to page_put_link(), saving a
hidden call to compound_head(). Also add kernel-doc for page_get_link()
and page_put_link().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/fuse/dir.c | 2 +-
fs/namei.c | 30 +++++++++++++++++++++++++++---
fs/nfs/symlink.c | 2 +-
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 83ac192e7fdd..33b82529cb6e 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1676,7 +1676,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode,
goto out_err;
}
- set_delayed_call(callback, page_put_link, &folio->page);
+ set_delayed_call(callback, page_put_link, folio);
return folio_address(folio);
diff --git a/fs/namei.c b/fs/namei.c
index 8e82aa7ecb82..12d24f6da782 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -5419,7 +5419,7 @@ static char *__page_get_link(struct dentry *dentry, struct inode *inode,
if (IS_ERR(folio))
return ERR_CAST(folio);
}
- set_delayed_call(callback, page_put_link, &folio->page);
+ set_delayed_call(callback, page_put_link, folio);
BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM);
return folio_address(folio);
}
@@ -5431,6 +5431,17 @@ const char *page_get_link_raw(struct dentry *dentry, struct inode *inode,
}
EXPORT_SYMBOL_GPL(page_get_link_raw);
+/**
+ * page_get_link() - An implementation of the get_link inode_operation.
+ * @dentry: The directory entry which is the symlink.
+ * @inode: The inode for the symlink.
+ * @callback: Used to drop the reference to the symlink.
+ *
+ * Filesystems which store their symlinks in the page cache should use
+ * this to implement the get_link() member of their inode_operations.
+ *
+ * Return: A pointer to the NUL-terminated symlink.
+ */
const char *page_get_link(struct dentry *dentry, struct inode *inode,
struct delayed_call *callback)
{
@@ -5440,12 +5451,25 @@ const char *page_get_link(struct dentry *dentry, struct inode *inode,
nd_terminate_link(kaddr, inode->i_size, PAGE_SIZE - 1);
return kaddr;
}
-
EXPORT_SYMBOL(page_get_link);
+/**
+ * page_put_link() - Drop the reference to the symlink.
+ * @arg: The folio which contains the symlink.
+ *
+ * This is used internally by page_get_link(). It is exported for use
+ * by filesystems which need to implement a variant of page_get_link()
+ * themselves. Despite the apparent symmetry, filesystems which use
+ * page_get_link() do not need to call page_put_link().
+ *
+ * The argument, while it has a void pointer type, must be a pointer to
+ * the folio which was retrieved from the page cache. The delayed_call
+ * infrastructure is used to drop the reference count once the caller
+ * is done with the symlink.
+ */
void page_put_link(void *arg)
{
- put_page(arg);
+ folio_put(arg);
}
EXPORT_SYMBOL(page_put_link);
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 004a8f6c568e..58146e935402 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -63,7 +63,7 @@ static const char *nfs_get_link(struct dentry *dentry,
if (IS_ERR(folio))
return ERR_CAST(folio);
}
- set_delayed_call(done, page_put_link, &folio->page);
+ set_delayed_call(done, page_put_link, folio);
return folio_address(folio);
}
--
2.47.2
next prev parent reply other threads:[~2025-05-14 17:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 17:13 [PATCH 0/3] Use folios for symlinks in the page cache Matthew Wilcox (Oracle)
2025-05-14 17:13 ` [PATCH 1/3] fs: Convert __page_get_link() to use a folio Matthew Wilcox (Oracle)
2025-05-14 17:13 ` [PATCH 2/3] nfs: Use a folio in nfs_get_link() Matthew Wilcox (Oracle)
2025-05-19 19:28 ` Anna Schumaker
2025-05-14 17:13 ` Matthew Wilcox (Oracle) [this message]
2025-05-15 10:14 ` [PATCH 0/3] Use folios for symlinks in the page cache Christian Brauner
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=20250514171316.3002934-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).