Skip to content

Commit 3e3a693

Browse files
Matthew Wilcox (Oracle)tytso
authored andcommitted
ext4: tidy the BH loop in mext_page_mkuptodate()
This for loop is somewhat hard to read; turn it into a normal BH do-while loop. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent a40759f commit 3e3a693

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/ext4/move_extent.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
187187
if (!head)
188188
head = create_empty_buffers(folio, blocksize, 0);
189189

190-
block = (sector_t)folio->index << (PAGE_SHIFT - inode->i_blkbits);
191-
for (bh = head, block_start = 0; bh != head || !block_start;
192-
block++, block_start = block_end, bh = bh->b_this_page) {
190+
block = folio_pos(folio) >> inode->i_blkbits;
191+
block_end = 0;
192+
bh = head;
193+
do {
194+
block_start = block_end;
193195
block_end = block_start + blocksize;
194196
if (block_end <= from || block_start >= to) {
195197
if (!buffer_uptodate(bh))
@@ -215,7 +217,8 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
215217
}
216218
ext4_read_bh_nowait(bh, 0, NULL);
217219
nr++;
218-
}
220+
} while (block++, (bh = bh->b_this_page) != head);
221+
219222
/* No io required */
220223
if (!nr)
221224
goto out;

0 commit comments

Comments
 (0)