Commit 26ecf243 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: stop using write_one_page in btrfs_scratch_superblock

write_one_page is an awkward interface that expects the page locked and
->writepage to be implemented.  Replace that by zeroing the signature
bytes and synchronize the block device page using the proper bdev
helpers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0e0078f7
...@@ -2018,23 +2018,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info, ...@@ -2018,23 +2018,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
struct block_device *bdev, int copy_num) struct block_device *bdev, int copy_num)
{ {
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
struct page *page; const size_t len = sizeof(disk_super->magic);
const u64 bytenr = btrfs_sb_offset(copy_num);
int ret; int ret;
disk_super = btrfs_read_dev_one_super(bdev, copy_num, false); disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr);
if (IS_ERR(disk_super)) if (IS_ERR(disk_super))
return; return;
memset(&disk_super->magic, 0, sizeof(disk_super->magic)); memset(&disk_super->magic, 0, len);
page = virt_to_page(disk_super); folio_mark_dirty(virt_to_folio(disk_super));
set_page_dirty(page); btrfs_release_disk_super(disk_super);
lock_page(page);
/* write_on_page() unlocks the page */ ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1);
ret = write_one_page(page);
if (ret) if (ret)
btrfs_warn(fs_info, "error clearing superblock number %d (%d)", btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
copy_num, ret); copy_num, ret);
btrfs_release_disk_super(disk_super);
} }
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment