Skip to content

Commit 617fb10

Browse files
Matthew Wilcox (Oracle)kdave
authored andcommitted
btrfs: use the folio iterator in btrfs_end_super_write()
Iterate over folios instead of bvecs. Switch the order of unlock and put to be the usual order; we know this folio can't be put until it's been waited for, but that's fragile. Remove the calls to ClearPageUptodate / SetPageUptodate -- if PAGE_SIZE is larger than BTRFS_SUPER_INFO_SIZE, we'd be marking the entire folio uptodate without having actually initialised all the bytes in the page. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f93ee0d commit 617fb10

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

fs/btrfs/disk-io.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,28 +3626,21 @@ ALLOW_ERROR_INJECTION(open_ctree, ERRNO);
36263626
static void btrfs_end_super_write(struct bio *bio)
36273627
{
36283628
struct btrfs_device *device = bio->bi_private;
3629-
struct bio_vec *bvec;
3630-
struct bvec_iter_all iter_all;
3631-
struct page *page;
3632-
3633-
bio_for_each_segment_all(bvec, bio, iter_all) {
3634-
page = bvec->bv_page;
3629+
struct folio_iter fi;
36353630

3631+
bio_for_each_folio_all(fi, bio) {
36363632
if (bio->bi_status) {
36373633
btrfs_warn_rl_in_rcu(device->fs_info,
3638-
"lost page write due to IO error on %s (%d)",
3634+
"lost super block write due to IO error on %s (%d)",
36393635
btrfs_dev_name(device),
36403636
blk_status_to_errno(bio->bi_status));
3641-
ClearPageUptodate(page);
3642-
SetPageError(page);
3637+
folio_set_error(fi.folio);
36433638
btrfs_dev_stat_inc_and_print(device,
36443639
BTRFS_DEV_STAT_WRITE_ERRS);
3645-
} else {
3646-
SetPageUptodate(page);
36473640
}
36483641

3649-
put_page(page);
3650-
unlock_page(page);
3642+
folio_unlock(fi.folio);
3643+
folio_put(fi.folio);
36513644
}
36523645

36533646
bio_put(bio);

0 commit comments

Comments
 (0)