summaryrefslogtreecommitdiffstats
path: root/fs/iomap
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2021-12-09 21:47:44 +0100
committerMatthew Wilcox (Oracle) <willy@infradead.org>2021-12-18 06:06:00 +0100
commitd454ab82bc7f4aa7af9f539d5cf9a1e237cdcbc2 (patch)
treef78a28ca4085a1c22e766b116073b237004c26cb /fs/iomap
parentiomap: Convert iomap_page_mkwrite to use a folio (diff)
downloadlinux-d454ab82bc7f4aa7af9f539d5cf9a1e237cdcbc2.tar.xz
linux-d454ab82bc7f4aa7af9f539d5cf9a1e237cdcbc2.zip
iomap: Allow iomap_write_begin() to be called with the full length
In the future, we want write_begin to know the entire length of the write so that it can choose to allocate large folios. Pass the full length in from __iomap_zero_iter() and limit it where necessary. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/iomap')
-rw-r--r--fs/iomap/buffered-io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 8d7a67655b60..b1ded5204d1c 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -619,6 +619,9 @@ static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
if (fatal_signal_pending(current))
return -EINTR;
+ if (!mapping_large_folio_support(iter->inode->i_mapping))
+ len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos));
+
if (page_ops && page_ops->page_prepare) {
status = page_ops->page_prepare(iter->inode, pos, len);
if (status)
@@ -632,6 +635,8 @@ static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
goto out_no_page;
}
folio = page_folio(page);
+ if (pos + len > folio_pos(folio) + folio_size(folio))
+ len = folio_pos(folio) + folio_size(folio) - pos;
if (srcmap->type == IOMAP_INLINE)
status = iomap_write_begin_inline(iter, page);
@@ -891,11 +896,13 @@ static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
struct page *page;
int status;
unsigned offset = offset_in_page(pos);
- unsigned bytes = min_t(u64, PAGE_SIZE - offset, length);
+ unsigned bytes = min_t(u64, UINT_MAX, length);
status = iomap_write_begin(iter, pos, bytes, &page);
if (status)
return status;
+ if (bytes > PAGE_SIZE - offset)
+ bytes = PAGE_SIZE - offset;
zero_user(page, offset, bytes);
mark_page_accessed(page);