summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2024-07-18 23:30:01 +0100
committerTheodore Ts'o <tytso@mit.edu>2024-08-26 21:47:03 -0400
commita40759fb16ae839f8c769174fde017564ea564ff (patch)
treea8dd4cb44a705911f7522772b06974aeb00fc485
parent368a83cebbb949adbcc20877c35367178497d9cc (diff)
downloadlinux-a40759fb16ae839f8c769174fde017564ea564ff.tar.gz
linux-a40759fb16ae839f8c769174fde017564ea564ff.tar.bz2
linux-a40759fb16ae839f8c769174fde017564ea564ff.zip
ext4: remove array of buffer_heads from mext_page_mkuptodate()
Iterate the folio's list of buffer_heads twice instead of keeping an array of pointers. This solves a too-large-array-for-stack problem on architectures with a ridiculoously large PAGE_SIZE and prepares ext4 to support larger folios. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://patch.msgid.link/20240718223005.568869-3-willy@infradead.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/ext4/move_extent.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 6d651ad788ac..660bf34a5c4b 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -166,15 +166,14 @@ mext_folio_double_lock(struct inode *inode1, struct inode *inode2,
return 0;
}
-/* Force page buffers uptodate w/o dropping page's lock */
-static int
-mext_page_mkuptodate(struct folio *folio, unsigned from, unsigned to)
+/* Force folio buffers uptodate w/o dropping folio's lock */
+static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
{
struct inode *inode = folio->mapping->host;
sector_t block;
- struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
+ struct buffer_head *bh, *head;
unsigned int blocksize, block_start, block_end;
- int i, nr = 0;
+ int nr = 0;
bool partial = false;
BUG_ON(!folio_test_locked(folio));
@@ -215,20 +214,23 @@ mext_page_mkuptodate(struct folio *folio, unsigned from, unsigned to)
continue;
}
ext4_read_bh_nowait(bh, 0, NULL);
- BUG_ON(nr >= MAX_BUF_PER_PAGE);
- arr[nr++] = bh;
+ nr++;
}
/* No io required */
if (!nr)
goto out;
- for (i = 0; i < nr; i++) {
- bh = arr[i];
+ bh = head;
+ do {
+ if (bh_offset(bh) + blocksize <= from)
+ continue;
+ if (bh_offset(bh) > to)
+ break;
wait_on_buffer(bh);
if (buffer_uptodate(bh))
continue;
return -EIO;
- }
+ } while ((bh = bh->b_this_page) != head);
out:
if (!partial)
folio_mark_uptodate(folio);