Skip to content

Commit 26ecf24

Browse files
Christoph Hellwigkdave
authored andcommitted
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 <[email protected]> Reviewed-by: David Sterba <[email protected]> [ update changelog ] Signed-off-by: David Sterba <[email protected]>
1 parent 0e0078f commit 26ecf24

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/btrfs/volumes.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,23 +2018,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
20182018
struct block_device *bdev, int copy_num)
20192019
{
20202020
struct btrfs_super_block *disk_super;
2021-
struct page *page;
2021+
const size_t len = sizeof(disk_super->magic);
2022+
const u64 bytenr = btrfs_sb_offset(copy_num);
20222023
int ret;
20232024

2024-
disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
2025+
disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr);
20252026
if (IS_ERR(disk_super))
20262027
return;
20272028

2028-
memset(&disk_super->magic, 0, sizeof(disk_super->magic));
2029-
page = virt_to_page(disk_super);
2030-
set_page_dirty(page);
2031-
lock_page(page);
2032-
/* write_on_page() unlocks the page */
2033-
ret = write_one_page(page);
2029+
memset(&disk_super->magic, 0, len);
2030+
folio_mark_dirty(virt_to_folio(disk_super));
2031+
btrfs_release_disk_super(disk_super);
2032+
2033+
ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1);
20342034
if (ret)
20352035
btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
20362036
copy_num, ret);
2037-
btrfs_release_disk_super(disk_super);
20382037
}
20392038

20402039
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,

0 commit comments

Comments
 (0)