summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-11-21 18:47:49 +0100
committerDavid Sterba <dsterba@suse.com>2023-01-16 19:46:19 +0100
commit26ecf243e407be54807ad67210f7e83b9fad71ea (patch)
tree633c8aed0da395c197465be7f640677dc0133268 /fs
parent0e0078f72be81bbb2a02b229fd2cec8ad63e4fb1 (diff)
downloadlinux-stable-26ecf243e407be54807ad67210f7e83b9fad71ea.tar.gz
linux-stable-26ecf243e407be54807ad67210f7e83b9fad71ea.tar.bz2
linux-stable-26ecf243e407be54807ad67210f7e83b9fad71ea.zip
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: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 119dc26ca141..bcfef75b97da 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2018,23 +2018,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
struct block_device *bdev, int copy_num)
{
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;
- 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))
return;
- memset(&disk_super->magic, 0, sizeof(disk_super->magic));
- page = virt_to_page(disk_super);
- set_page_dirty(page);
- lock_page(page);
- /* write_on_page() unlocks the page */
- ret = write_one_page(page);
+ memset(&disk_super->magic, 0, len);
+ folio_mark_dirty(virt_to_folio(disk_super));
+ btrfs_release_disk_super(disk_super);
+
+ ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1);
if (ret)
btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
copy_num, ret);
- btrfs_release_disk_super(disk_super);
}
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,