From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Christoph Hellwig <hch@lst.de>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: [PATCH 4/7] fs: Add filemap_symlink()
Date: Tue, 28 May 2024 17:48:25 +0100 [thread overview]
Message-ID: <20240528164829.2105447-5-willy@infradead.org> (raw)
In-Reply-To: <20240528164829.2105447-1-willy@infradead.org>
This is the equivalent of page_symlink() but takes a
buffered_write_operations structure. It also doesn't handle GFP_NOFS
for you; if you need that, use memalloc_nofs_save() yourself.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/namei.c | 25 +++++++++++++++++++++++++
include/linux/pagemap.h | 2 ++
2 files changed, 27 insertions(+)
diff --git a/fs/namei.c b/fs/namei.c
index 37fb0a8aa09a..4352206b0408 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -5255,6 +5255,31 @@ int page_symlink(struct inode *inode, const char *symname, int len)
}
EXPORT_SYMBOL(page_symlink);
+int filemap_symlink(struct inode *inode, const char *symname, int len,
+ const struct buffered_write_operations *ops, void **fsdata)
+{
+ struct address_space *mapping = inode->i_mapping;
+ struct folio *folio;
+ int err;
+
+retry:
+ folio = ops->write_begin(NULL, mapping, 0, len-1, fsdata);
+ if (IS_ERR(folio))
+ return PTR_ERR(folio);
+
+ memcpy(folio_address(folio), symname, len-1);
+
+ err = ops->write_end(NULL, mapping, 0, len-1, len-1, folio, fsdata);
+ if (err < 0)
+ return err;
+ if (err < len-1)
+ goto retry;
+
+ mark_inode_dirty(inode);
+ return 0;
+}
+EXPORT_SYMBOL(filemap_symlink);
+
const struct inode_operations page_symlink_inode_operations = {
.get_link = page_get_link,
};
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 2921c1cc6335..a7540f757368 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -39,6 +39,8 @@ ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
#define __generic_file_write_iter(kiocb, iter) \
__filemap_write_iter(kiocb, iter, NULL, NULL)
+int filemap_symlink(struct inode *inode, const char *symname, int len,
+ const struct buffered_write_operations *bw, void **fsdata);
unsigned long invalidate_mapping_pages(struct address_space *mapping,
pgoff_t start, pgoff_t end);
--
2.43.0
next prev parent reply other threads:[~2024-05-28 16:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 16:48 [PATCH 0/7] Start moving write_begin/write_end out of aops Matthew Wilcox (Oracle)
2024-05-28 16:48 ` [PATCH 1/7] fs: Introduce buffered_write_operations Matthew Wilcox (Oracle)
2024-05-28 23:42 ` kernel test robot
2024-05-29 5:21 ` Christoph Hellwig
2024-05-28 16:48 ` [PATCH 2/7] fs: Supply optional buffered_write_operations in buffer.c Matthew Wilcox (Oracle)
2024-05-28 16:48 ` [PATCH 3/7] buffer: Add buffer_write_begin, buffer_write_end and __buffer_write_end Matthew Wilcox (Oracle)
2024-05-28 16:48 ` Matthew Wilcox (Oracle) [this message]
2024-05-28 16:48 ` [PATCH 5/7] ext2: Convert to buffered_write_operations Matthew Wilcox (Oracle)
2024-05-28 16:48 ` [PATCH 6/7] ext4: " Matthew Wilcox (Oracle)
2024-05-28 23:42 ` kernel test robot
2024-05-28 16:48 ` [PATCH 7/7] iomap: Return the folio from iomap_write_begin() Matthew Wilcox (Oracle)
2024-05-28 23:31 ` kernel test robot
2024-05-28 23:44 ` Dave Chinner
2024-05-29 5:25 ` Christoph Hellwig
2024-05-29 5:20 ` [PATCH 0/7] Start moving write_begin/write_end out of aops 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=20240528164829.2105447-5-willy@infradead.org \
--to=willy@infradead.org \
--cc=hch@lst.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).