]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/buffer: simplify block_read_full_folio() with bh_offset()
authorLuis Chamberlain <mcgrof@kernel.org>
Fri, 21 Feb 2025 22:38:16 +0000 (14:38 -0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 24 Feb 2025 10:44:43 +0000 (11:44 +0100)
When we read over all buffers in a folio we currently use the
buffer index on the folio and blocksize to get the offset. Simplify
this with bh_offset(). This simplifies the loop while making no
functional changes.

Suggested-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250221223823.1680616-2-mcgrof@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/buffer.c

index cc8452f6025167630bfe42d8f6652c74adfbdedd..b99560e8a142a53e76d501825704cbf9aac0ea77 100644 (file)
@@ -2381,7 +2381,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
        lblock = div_u64(limit + blocksize - 1, blocksize);
        bh = head;
        nr = 0;
-       i = 0;
 
        do {
                if (buffer_uptodate(bh))
@@ -2398,7 +2397,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
                                        page_error = true;
                        }
                        if (!buffer_mapped(bh)) {
-                               folio_zero_range(folio, i * blocksize,
+                               folio_zero_range(folio, bh_offset(bh),
                                                blocksize);
                                if (!err)
                                        set_buffer_uptodate(bh);
@@ -2412,7 +2411,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
                                continue;
                }
                arr[nr++] = bh;
-       } while (i++, iblock++, (bh = bh->b_this_page) != head);
+       } while (iblock++, (bh = bh->b_this_page) != head);
 
        if (fully_mapped)
                folio_set_mappedtodisk(folio);