Re: [RFC v4 linux-next 03/19] block: remove sync_blockdev_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 22-02-24 20:45:39, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@xxxxxxxxxx>
> 
> Now that all filesystems stash the bdev file, it's ok to flush the file
> mapping directly.
> 
> Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  block/bdev.c           |  7 -------
>  fs/btrfs/dev-replace.c |  2 +-
>  fs/btrfs/volumes.c     | 19 +++++++++++--------
>  fs/btrfs/volumes.h     |  2 +-
>  fs/exfat/fatent.c      |  2 +-
>  include/linux/blkdev.h |  1 -
>  6 files changed, 14 insertions(+), 19 deletions(-)
> 
> diff --git a/block/bdev.c b/block/bdev.c
> index 49dcff483289..e493d5c72edb 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -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
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 7057221a46c3..88d45118cc64 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -982,7 +982,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
>  	btrfs_sysfs_remove_device(src_device);
>  	btrfs_sysfs_update_devid(tgt_device);
>  	if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &src_device->dev_state))
> -		btrfs_scratch_superblocks(fs_info, src_device->bdev,
> +		btrfs_scratch_superblocks(fs_info, src_device->bdev_file,
>  					  src_device->name->str);
>  
>  	/* write back the superblocks */
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 493e33b4ae94..e12451ff911a 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2033,14 +2033,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;
>  
> @@ -2048,26 +2048,29 @@ 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);
>  }
>  
>  void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
> -			       struct block_device *bdev,
> +			       struct file *bdev_file,
>  			       const char *device_path)
>  {
> +	struct block_device *bdev;
>  	int copy_num;
>  
> -	if (!bdev)
> +	if (!bdev_file)
>  		return;
>  
> +	bdev = file_bdev(bdev_file);
>  	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 */
> @@ -2209,7 +2212,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
>  	 *  just flush the device and let the caller do the final bdev_release.
>  	 */
>  	if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
> -		btrfs_scratch_superblocks(fs_info, device->bdev,
> +		btrfs_scratch_superblocks(fs_info, device->bdev_file,
>  					  device->name->str);
>  		if (device->bdev) {
>  			sync_blockdev(device->bdev);
> @@ -2323,7 +2326,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev)
>  
>  	mutex_unlock(&fs_devices->device_list_mutex);
>  
> -	btrfs_scratch_superblocks(tgtdev->fs_info, tgtdev->bdev,
> +	btrfs_scratch_superblocks(tgtdev->fs_info, tgtdev->bdev_file,
>  				  tgtdev->name->str);
>  
>  	btrfs_close_bdev(tgtdev);
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index 2ef78d3cc4c3..1d566f40b83d 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -818,7 +818,7 @@ struct list_head * __attribute_const__ btrfs_get_fs_uuids(void);
>  bool btrfs_check_rw_degradable(struct btrfs_fs_info *fs_info,
>  					struct btrfs_device *failing_dev);
>  void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
> -			       struct block_device *bdev,
> +			       struct file *bdev_file,
>  			       const char *device_path);
>  
>  enum btrfs_raid_types __attribute_const__ btrfs_bg_flags_to_raid_index(u64 flags);
> diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
> index 56b870d9cc0d..1c86ec2465b7 100644
> --- a/fs/exfat/fatent.c
> +++ b/fs/exfat/fatent.c
> @@ -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);
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 9e96811c8915..c510f334c84f 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1527,7 +1527,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);
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux