From: Andreas Gruenbacher <agruenba@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
cluster-devel@redhat.com, Bob Peterson <rpeterso@redhat.com>,
Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 2/2] iomap: Add helper for un-inlining an inline inode
Date: Mon, 28 Jun 2021 19:27:27 +0200 [thread overview]
Message-ID: <20210628172727.1894503-3-agruenba@redhat.com> (raw)
In-Reply-To: <20210628172727.1894503-1-agruenba@redhat.com>
From: Bob Peterson <rpeterso@redhat.com>
Add function iomap_uninline_inode for converting an inline inode into a
non-inline inode. This takes care of attaching a new iomap_page object
to page->private if the block size is smaller than the page size.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/iomap/buffered-io.c | 24 ++++++++++++++++++++++++
include/linux/iomap.h | 2 ++
2 files changed, 26 insertions(+)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 03537ecb2a94..44acb59191b2 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -226,6 +226,30 @@ iomap_read_inline_data(struct inode *inode, struct page *page,
SetPageUptodate(page);
}
+int iomap_uninline_inode(struct inode *inode,
+ int (*uninline)(struct inode *, struct page *))
+{
+ struct page *page = NULL;
+ int ret;
+
+ if (i_size_read(inode)) {
+ page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);
+ if (!page)
+ return -ENOMEM;
+ }
+ ret = uninline(inode, page);
+ if (page) {
+ if (PageUptodate(page)) {
+ iomap_page_create(inode, page);
+ iomap_set_range_uptodate(page, 0, PAGE_SIZE);
+ }
+ unlock_page(page);
+ put_page(page);
+ }
+ return ret;
+}
+EXPORT_SYMBOL_GPL(iomap_uninline_inode);
+
static inline bool iomap_block_needs_zeroing(struct inode *inode,
struct iomap *iomap, loff_t pos)
{
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index c87d0cb0de6d..90c924eec09b 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -157,6 +157,8 @@ loff_t iomap_apply(struct inode *inode, loff_t pos, loff_t length,
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
const struct iomap_ops *ops);
+int iomap_uninline_inode(struct inode *inode,
+ int (*uninline)(struct inode *, struct page *));
int iomap_readpage(struct page *page, const struct iomap_ops *ops);
void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops);
int iomap_set_page_dirty(struct page *page);
--
2.26.3
next prev parent reply other threads:[~2021-06-28 17:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 17:27 [PATCH 0/2] iomap: small block problems Andreas Gruenbacher
2021-06-28 17:27 ` [PATCH 1/2] iomap: Don't create iomap_page objects for inline files Andreas Gruenbacher
2021-06-30 13:35 ` Matthew Wilcox
2021-06-28 17:27 ` Andreas Gruenbacher [this message]
2021-06-28 17:39 ` [PATCH 0/2] iomap: small block problems Matthew Wilcox
2021-06-28 17:47 ` Christoph Hellwig
2021-06-28 21:28 ` Andreas Gruenbacher
2021-06-28 21:59 ` Matthew Wilcox
2021-06-29 5:29 ` Christoph Hellwig
2021-06-29 5:42 ` Christoph Hellwig
2021-06-30 12:29 ` Andreas Gruenbacher
2021-07-05 15:51 ` Andreas Gruenbacher
2021-07-05 16:55 ` Christoph Hellwig
2021-06-28 17:55 ` Andreas Gruenbacher
2021-06-29 9:12 ` Andreas Gruenbacher
2021-06-30 14:08 ` Matthew Wilcox
2021-06-30 14:45 ` Andreas Gruenbacher
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=20210628172727.1894503-3-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=rpeterso@redhat.com \
/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).