@@ -3734,13 +3734,13 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev)
3734
3734
3735
3735
/*
3736
3736
* 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.
3738
3738
*
3739
3739
* Write @max_mirrors copies of the superblock, where 0 means default that fit
3740
3740
* the expected device size at commit time. Note that max_mirrors must be
3741
3741
* same for write and wait phases.
3742
3742
*
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.
3744
3744
*/
3745
3745
static int write_dev_supers (struct btrfs_device * device ,
3746
3746
struct btrfs_super_block * sb , int max_mirrors )
@@ -3759,9 +3759,10 @@ static int write_dev_supers(struct btrfs_device *device,
3759
3759
shash -> tfm = fs_info -> csum_shash ;
3760
3760
3761
3761
for (i = 0 ; i < max_mirrors ; i ++ ) {
3762
- struct page * page ;
3762
+ struct folio * folio ;
3763
3763
struct bio * bio ;
3764
3764
struct btrfs_super_block * disk_super ;
3765
+ size_t offset ;
3765
3766
3766
3767
bytenr_orig = btrfs_sb_offset (i );
3767
3768
ret = btrfs_sb_log_location (device , i , WRITE , & bytenr );
@@ -3784,20 +3785,23 @@ static int write_dev_supers(struct btrfs_device *device,
3784
3785
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE ,
3785
3786
sb -> csum );
3786
3787
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 )) {
3790
3792
btrfs_err (device -> fs_info ,
3791
3793
"couldn't get super block page for bytenr %llu" ,
3792
3794
bytenr );
3793
3795
errors ++ ;
3794
3796
continue ;
3795
3797
}
3798
+ ASSERT (folio_order (folio ) == 0 );
3796
3799
3797
3800
/* Bump the refcount for wait_dev_supers() */
3798
- get_page ( page );
3801
+ folio_get ( folio );
3799
3802
3800
- disk_super = page_address (page );
3803
+ offset = offset_in_folio (folio , bytenr );
3804
+ disk_super = folio_address (folio ) + offset ;
3801
3805
memcpy (disk_super , sb , BTRFS_SUPER_INFO_SIZE );
3802
3806
3803
3807
/*
@@ -3811,8 +3815,7 @@ static int write_dev_supers(struct btrfs_device *device,
3811
3815
bio -> bi_iter .bi_sector = bytenr >> SECTOR_SHIFT ;
3812
3816
bio -> bi_private = device ;
3813
3817
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 );
3816
3819
3817
3820
/*
3818
3821
* We FUA only the first super block. The others we allow to
0 commit comments