From: Jan Kara <jack@suse.cz>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: jack@suse.cz, hch@lst.de, brauner@kernel.org, axboe@kernel.dk,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [RFC v4 linux-next 03/19] block: remove sync_blockdev_range()
Date: Fri, 15 Mar 2024 15:37:56 +0100 [thread overview]
Message-ID: <20240315143756.gpbks7bmj7ivx6qv@quack3> (raw)
In-Reply-To: <20240222124555.2049140-4-yukuai1@huaweicloud.com>
On Thu 22-02-24 20:45:39, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Now that all filesystems stash the bdev file, it's ok to flush the file
> mapping directly.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
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@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-03-15 14:37 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 12:45 [RFC v4 linux-next 00/19] fs & block: remove bdev->bd_inode Yu Kuai
2024-02-22 12:45 ` [RFC v4 linux-next 01/19] block: move two helpers into bdev.c Yu Kuai
2024-03-15 14:31 ` Jan Kara
2024-03-17 21:19 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 02/19] block: remove sync_blockdev_nowait() Yu Kuai
2024-03-15 14:34 ` Jan Kara
2024-03-17 21:19 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 03/19] block: remove sync_blockdev_range() Yu Kuai
2024-03-15 14:37 ` Jan Kara [this message]
2024-03-17 21:21 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 04/19] block: prevent direct access of bd_inode Yu Kuai
2024-03-15 14:44 ` Jan Kara
2024-03-17 21:23 ` Christoph Hellwig
2024-03-22 5:44 ` Al Viro
2024-02-22 12:45 ` [RFC v4 linux-next 05/19] bcachefs: remove dead function bdev_sectors() Yu Kuai
2024-03-15 14:42 ` Jan Kara
2024-03-17 21:23 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 06/19] cramfs: prevent direct access of bd_inode Yu Kuai
2024-03-15 14:44 ` Jan Kara
2024-03-17 21:23 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 07/19] erofs: " Yu Kuai
2024-03-15 14:45 ` Jan Kara
2024-03-17 21:24 ` Christoph Hellwig
2024-03-18 2:39 ` Gao Xiang
2024-02-22 12:45 ` [RFC v4 linux-next 08/19] nilfs2: " Yu Kuai
2024-03-15 14:49 ` Jan Kara
2024-03-17 21:24 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 09/19] gfs2: " Yu Kuai
2024-03-15 14:54 ` Jan Kara
2024-03-17 21:24 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 10/19] s390/dasd: use bdev api in dasd_format() Yu Kuai
2024-03-15 14:55 ` Jan Kara
2024-03-17 21:25 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 11/19] btrfs: prevent direct access of bd_inode Yu Kuai
2024-03-15 15:09 ` Jan Kara
2024-03-17 21:25 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 12/19] ext4: remove block_device_ejected() Yu Kuai
2024-02-22 12:45 ` [RFC v4 linux-next 13/19] ext4: prevent direct access of bd_inode Yu Kuai
2024-03-15 14:58 ` Jan Kara
2024-03-17 21:25 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 14/19] jbd2: " Yu Kuai
2024-03-15 15:06 ` Jan Kara
2024-03-17 21:26 ` Christoph Hellwig
2024-03-18 1:10 ` Yu Kuai
2024-02-22 12:45 ` [RFC v4 linux-next 15/19] bcache: " Yu Kuai
2024-03-15 15:11 ` Jan Kara
2024-03-17 21:34 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 16/19] block2mtd: " Yu Kuai
2024-03-15 15:12 ` Jan Kara
2024-03-17 21:36 ` Christoph Hellwig
2024-02-22 12:45 ` [RFC v4 linux-next 17/19] dm-vdo: " Yu Kuai
2024-02-28 13:41 ` Christoph Hellwig
2024-03-18 9:11 ` Jan Kara
2024-03-18 9:19 ` Jan Kara
2024-03-18 13:38 ` Yu Kuai
2024-03-19 2:00 ` Matthew Sakai
2024-02-22 12:45 ` [RFC v4 linux-next 18/19] scsi: factor out a helper bdev_read_folio() from scsi_bios_ptable() Yu Kuai
2024-03-17 21:36 ` Christoph Hellwig
2024-03-18 1:12 ` Yu Kuai
2024-03-18 9:22 ` Jan Kara
2024-02-22 12:45 ` [RFC v4 linux-next 19/19] fs & block: remove bdev->bd_inode Yu Kuai
2024-03-17 21:38 ` Christoph Hellwig
2024-03-18 1:26 ` Yu Kuai
2024-03-18 1:32 ` Christoph Hellwig
2024-03-18 1:51 ` Yu Kuai
2024-03-18 7:19 ` Yu Kuai
2024-03-18 10:07 ` Christian Brauner
2024-03-18 10:29 ` Christian Brauner
2024-03-18 10:46 ` Christian Brauner
2024-03-18 11:57 ` Yu Kuai
2024-03-18 23:35 ` Christoph Hellwig
2024-03-18 23:22 ` Christoph Hellwig
2024-03-19 8:26 ` Yu Kuai
2024-03-21 11:27 ` Jan Kara
2024-03-21 12:15 ` Yu Kuai
2024-03-22 6:37 ` Al Viro
2024-03-22 6:39 ` Al Viro
2024-03-22 6:52 ` Yu Kuai
2024-03-22 12:57 ` Jan Kara
2024-03-22 13:57 ` Christian Brauner
2024-03-22 15:43 ` Al Viro
2024-03-22 16:16 ` Al Viro
2024-03-22 6:33 ` Al Viro
2024-03-22 7:09 ` Yu Kuai
2024-03-22 16:01 ` Al Viro
2024-03-22 13:10 ` Jan Kara
2024-03-22 14:57 ` Al Viro
2024-03-25 1:06 ` Christoph Hellwig
2024-02-28 13:42 ` [RFC v4 linux-next 00/19] " Christoph Hellwig
2024-03-15 12:08 ` Yu Kuai
2024-03-15 13:54 ` Christian Brauner
2024-03-16 2:49 ` Yu Kuai
2024-03-18 9:39 ` Christian Brauner
2024-03-19 1:18 ` Yu Kuai
2024-03-19 1:43 ` Yu Kuai
2024-03-19 2:13 ` Matthew Sakai
2024-03-19 2:27 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240315143756.gpbks7bmj7ivx6qv@quack3 \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox