Skip to content

Commit f93ee0d

Browse files
Matthew Wilcox (Oracle)kdave
Matthew Wilcox (Oracle)
authored andcommitted
btrfs: convert super block writes to folio in write_dev_supers()
This is a direct conversion from pages to folios, assuming single page folio. Also removes some calls to obsolete APIs and some hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c94b734 commit f93ee0d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

fs/btrfs/disk-io.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,13 +3734,13 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev)
37343734

37353735
/*
37363736
* Write superblock @sb to the @device. Do not wait for completion, all the
3737-
* pages we use for writing are locked.
3737+
* folios we use for writing are locked.
37383738
*
37393739
* Write @max_mirrors copies of the superblock, where 0 means default that fit
37403740
* the expected device size at commit time. Note that max_mirrors must be
37413741
* same for write and wait phases.
37423742
*
3743-
* Return number of errors when page is not found or submission fails.
3743+
* Return number of errors when folio is not found or submission fails.
37443744
*/
37453745
static int write_dev_supers(struct btrfs_device *device,
37463746
struct btrfs_super_block *sb, int max_mirrors)
@@ -3759,9 +3759,10 @@ static int write_dev_supers(struct btrfs_device *device,
37593759
shash->tfm = fs_info->csum_shash;
37603760

37613761
for (i = 0; i < max_mirrors; i++) {
3762-
struct page *page;
3762+
struct folio *folio;
37633763
struct bio *bio;
37643764
struct btrfs_super_block *disk_super;
3765+
size_t offset;
37653766

37663767
bytenr_orig = btrfs_sb_offset(i);
37673768
ret = btrfs_sb_log_location(device, i, WRITE, &bytenr);
@@ -3784,20 +3785,23 @@ static int write_dev_supers(struct btrfs_device *device,
37843785
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE,
37853786
sb->csum);
37863787

3787-
page = find_or_create_page(mapping, bytenr >> PAGE_SHIFT,
3788-
GFP_NOFS);
3789-
if (!page) {
3788+
folio = __filemap_get_folio(mapping, bytenr >> PAGE_SHIFT,
3789+
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
3790+
GFP_NOFS);
3791+
if (IS_ERR(folio)) {
37903792
btrfs_err(device->fs_info,
37913793
"couldn't get super block page for bytenr %llu",
37923794
bytenr);
37933795
errors++;
37943796
continue;
37953797
}
3798+
ASSERT(folio_order(folio) == 0);
37963799

37973800
/* Bump the refcount for wait_dev_supers() */
3798-
get_page(page);
3801+
folio_get(folio);
37993802

3800-
disk_super = page_address(page);
3803+
offset = offset_in_folio(folio, bytenr);
3804+
disk_super = folio_address(folio) + offset;
38013805
memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE);
38023806

38033807
/*
@@ -3811,8 +3815,7 @@ static int write_dev_supers(struct btrfs_device *device,
38113815
bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT;
38123816
bio->bi_private = device;
38133817
bio->bi_end_io = btrfs_end_super_write;
3814-
__bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE,
3815-
offset_in_page(bytenr));
3818+
bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, offset);
38163819

38173820
/*
38183821
* We FUA only the first super block. The others we allow to

0 commit comments

Comments
 (0)