mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-21 06:50:25 +00:00
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) <willy@infradead.org> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
c94b7349b8
commit
f93ee0df51
1 changed files with 13 additions and 10 deletions
|
@ -3734,13 +3734,13 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write superblock @sb to the @device. Do not wait for completion, all the
|
* Write superblock @sb to the @device. Do not wait for completion, all the
|
||||||
* pages we use for writing are locked.
|
* folios we use for writing are locked.
|
||||||
*
|
*
|
||||||
* Write @max_mirrors copies of the superblock, where 0 means default that fit
|
* Write @max_mirrors copies of the superblock, where 0 means default that fit
|
||||||
* the expected device size at commit time. Note that max_mirrors must be
|
* the expected device size at commit time. Note that max_mirrors must be
|
||||||
* same for write and wait phases.
|
* same for write and wait phases.
|
||||||
*
|
*
|
||||||
* Return number of errors when page is not found or submission fails.
|
* Return number of errors when folio is not found or submission fails.
|
||||||
*/
|
*/
|
||||||
static int write_dev_supers(struct btrfs_device *device,
|
static int write_dev_supers(struct btrfs_device *device,
|
||||||
struct btrfs_super_block *sb, int max_mirrors)
|
struct btrfs_super_block *sb, int max_mirrors)
|
||||||
|
@ -3759,9 +3759,10 @@ static int write_dev_supers(struct btrfs_device *device,
|
||||||
shash->tfm = fs_info->csum_shash;
|
shash->tfm = fs_info->csum_shash;
|
||||||
|
|
||||||
for (i = 0; i < max_mirrors; i++) {
|
for (i = 0; i < max_mirrors; i++) {
|
||||||
struct page *page;
|
struct folio *folio;
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
struct btrfs_super_block *disk_super;
|
struct btrfs_super_block *disk_super;
|
||||||
|
size_t offset;
|
||||||
|
|
||||||
bytenr_orig = btrfs_sb_offset(i);
|
bytenr_orig = btrfs_sb_offset(i);
|
||||||
ret = btrfs_sb_log_location(device, i, WRITE, &bytenr);
|
ret = btrfs_sb_log_location(device, i, WRITE, &bytenr);
|
||||||
|
@ -3784,20 +3785,23 @@ static int write_dev_supers(struct btrfs_device *device,
|
||||||
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE,
|
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE,
|
||||||
sb->csum);
|
sb->csum);
|
||||||
|
|
||||||
page = find_or_create_page(mapping, bytenr >> PAGE_SHIFT,
|
folio = __filemap_get_folio(mapping, bytenr >> PAGE_SHIFT,
|
||||||
GFP_NOFS);
|
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
|
||||||
if (!page) {
|
GFP_NOFS);
|
||||||
|
if (IS_ERR(folio)) {
|
||||||
btrfs_err(device->fs_info,
|
btrfs_err(device->fs_info,
|
||||||
"couldn't get super block page for bytenr %llu",
|
"couldn't get super block page for bytenr %llu",
|
||||||
bytenr);
|
bytenr);
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
ASSERT(folio_order(folio) == 0);
|
||||||
|
|
||||||
/* Bump the refcount for wait_dev_supers() */
|
/* Bump the refcount for wait_dev_supers() */
|
||||||
get_page(page);
|
folio_get(folio);
|
||||||
|
|
||||||
disk_super = page_address(page);
|
offset = offset_in_folio(folio, bytenr);
|
||||||
|
disk_super = folio_address(folio) + offset;
|
||||||
memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE);
|
memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3811,8 +3815,7 @@ static int write_dev_supers(struct btrfs_device *device,
|
||||||
bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT;
|
bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT;
|
||||||
bio->bi_private = device;
|
bio->bi_private = device;
|
||||||
bio->bi_end_io = btrfs_end_super_write;
|
bio->bi_end_io = btrfs_end_super_write;
|
||||||
__bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE,
|
bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, offset);
|
||||||
offset_in_page(bytenr));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We FUA only the first super block. The others we allow to
|
* We FUA only the first super block. The others we allow to
|
||||||
|
|
Loading…
Add table
Reference in a new issue