Skip to content

Commit 753aade

Browse files
mcgrofbrauner
authored andcommitted
fs/buffer: simplify block_read_full_folio() with bh_offset()
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 <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 2014c95 commit 753aade

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/buffer.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
23812381
lblock = div_u64(limit + blocksize - 1, blocksize);
23822382
bh = head;
23832383
nr = 0;
2384-
i = 0;
23852384

23862385
do {
23872386
if (buffer_uptodate(bh))
@@ -2398,7 +2397,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
23982397
page_error = true;
23992398
}
24002399
if (!buffer_mapped(bh)) {
2401-
folio_zero_range(folio, i * blocksize,
2400+
folio_zero_range(folio, bh_offset(bh),
24022401
blocksize);
24032402
if (!err)
24042403
set_buffer_uptodate(bh);
@@ -2412,7 +2411,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
24122411
continue;
24132412
}
24142413
arr[nr++] = bh;
2415-
} while (i++, iblock++, (bh = bh->b_this_page) != head);
2414+
} while (iblock++, (bh = bh->b_this_page) != head);
24162415

24172416
if (fully_mapped)
24182417
folio_set_mappedtodisk(folio);

0 commit comments

Comments
 (0)