]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: tidy the BH loop in mext_page_mkuptodate()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 18 Jul 2024 22:30:02 +0000 (23:30 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 27 Aug 2024 01:47:04 +0000 (21:47 -0400)
This for loop is somewhat hard to read; turn it into a normal BH
do-while loop.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20240718223005.568869-4-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/move_extent.c

index 660bf34a5c4b852730bd25373d311b27228d8a4a..516897b0218e3367fd8a743c701da171c4d3f4c5 100644 (file)
@@ -187,9 +187,11 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
        if (!head)
                head = create_empty_buffers(folio, blocksize, 0);
 
-       block = (sector_t)folio->index << (PAGE_SHIFT - inode->i_blkbits);
-       for (bh = head, block_start = 0; bh != head || !block_start;
-            block++, block_start = block_end, bh = bh->b_this_page) {
+       block = folio_pos(folio) >> inode->i_blkbits;
+       block_end = 0;
+       bh = head;
+       do {
+               block_start = block_end;
                block_end = block_start + blocksize;
                if (block_end <= from || block_start >= to) {
                        if (!buffer_uptodate(bh))
@@ -215,7 +217,8 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
                }
                ext4_read_bh_nowait(bh, 0, NULL);
                nr++;
-       }
+       } while (block++, (bh = bh->b_this_page) != head);
+
        /* No io required */
        if (!nr)
                goto out;