]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: remove array of buffer_heads from mext_page_mkuptodate()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 18 Jul 2024 22:30:01 +0000 (23:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:52:48 +0000 (13:52 +0100)
[ Upstream commit a40759fb16ae839f8c769174fde017564ea564ff ]

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>
Stable-dep-of: 2f3d93e210b9 ("ext4: fix race in buffer_head read fault injection")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext4/move_extent.c

index 7a80c32fd7326ecf1852e2f7af698cae5d43abd5..42b52b6491a03b59cd5b3b617d635d7b1908e343 100644 (file)
@@ -165,15 +165,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));
@@ -214,20 +213,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);