@@ -200,13 +200,6 @@ int sync_blockdev(struct block_device *bdev)
}
EXPORT_SYMBOL(sync_blockdev);
-int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend)
-{
- return filemap_write_and_wait_range(bdev->bd_inode->i_mapping,
- lstart, lend);
-}
-EXPORT_SYMBOL(sync_blockdev_range);
-
/**
* bdev_freeze - lock a filesystem and force it into a consistent state
* @bdev: blockdevice to lock
@@ -2050,14 +2050,14 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info)
}
static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
- struct block_device *bdev, int copy_num)
+ struct file *bdev_file, int copy_num)
{
struct btrfs_super_block *disk_super;
const size_t len = sizeof(disk_super->magic);
const u64 bytenr = btrfs_sb_offset(copy_num);
int ret;
- disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr);
+ disk_super = btrfs_read_disk_super(file_bdev(bdev_file), bytenr, bytenr);
if (IS_ERR(disk_super))
return;
@@ -2065,7 +2065,8 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
folio_mark_dirty(virt_to_folio(disk_super));
btrfs_release_disk_super(disk_super);
- ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1);
+ ret = filemap_write_and_wait_range(bdev_file->f_mapping,
+ bytenr, bytenr + len - 1);
if (ret)
btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
copy_num, ret);
@@ -2075,15 +2076,16 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, struct btrfs_devic
{
int copy_num;
struct block_device *bdev = device->bdev;
+ struct file *bdev_file = device->bdev_file;
- if (!bdev)
+ if (!bdev || !bdev_file)
return;
for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) {
if (bdev_is_zoned(bdev))
btrfs_reset_sb_log_zones(bdev, copy_num);
else
- btrfs_scratch_superblock(fs_info, bdev, copy_num);
+ btrfs_scratch_superblock(fs_info, bdev_file, copy_num);
}
/* Notify udev that device has changed */
@@ -296,7 +296,7 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
}
if (IS_DIRSYNC(dir))
- return sync_blockdev_range(sb->s_bdev,
+ return filemap_write_and_wait_range(sb->s_bdev_file->f_mapping,
EXFAT_BLK_TO_B(blknr, sb),
EXFAT_BLK_TO_B(last_blknr, sb) - 1);
@@ -1532,7 +1532,6 @@ unsigned int block_size(struct block_device *bdev);
#ifdef CONFIG_BLOCK
void invalidate_bdev(struct block_device *bdev);
int sync_blockdev(struct block_device *bdev);
-int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend);
void sync_bdevs(bool wait);
void bdev_statx_dioalign(struct inode *inode, struct kstat *stat);
void printk_all_partitions(void);