remove revalidate_disk()
Subsystems (17)
Christoph Hellwig
maintainerHi Jens,
this series removes the revalidate_disk() function, which has been a really odd duck in the last years. The prime reason why most people use it is because it propagates a size change from the gendisk to the block_device structure. But it also calls into the rather ill defined ->revalidate_disk method which is rather useless for the callers. So this adds a new helper to just propagate the size, and cleans up all kinds of mess around this area. Follow on patches will eventuall kill of ->revalidate_disk entirely, but ther are a lot more patches needed for that.
Diffstat:
Documentation/filesystems/locking.rst | 3 -- block/genhd.c | 9 ++---- drivers/block/nbd.c | 8 ++--- drivers/block/rbd.c | 2 - drivers/block/rnbd/rnbd-clt.c | 10 +------ drivers/block/virtio_blk.c | 2 - drivers/block/zram/zram_drv.c | 4 +- drivers/md/dm-raid.c | 2 - drivers/md/md-cluster.c | 6 ++-- drivers/md/md-linear.c | 2 - drivers/md/md.c | 10 +++---- drivers/md/md.h | 2 - drivers/nvdimm/blk.c | 3 -- drivers/nvdimm/btt.c | 3 -- drivers/nvdimm/bus.c | 9 ++---- drivers/nvdimm/nd.h | 2 - drivers/nvdimm/pmem.c | 3 -- drivers/nvme/host/core.c | 16 +++++++---- drivers/scsi/sd.c | 6 ++-- fs/block_dev.c | 46 ++++++++++++++++------------------ include/linux/blk_types.h | 4 ++ include/linux/genhd.h | 6 ++-- 22 files changed, 74 insertions(+), 84 deletions(-)
Christoph Hellwig
maintainerPATCH 1/9 Documentation/filesystems/locking.rst: remove an incorrect sentence
unlock_native_capacity is never called from check_disk_change(), and while revalidate_disk can be called from it, it can also be called from two other places at the moment.
--- Documentation/filesystems/locking.rst | 3 --- 1 file changed, 3 deletions(-)
Documentation/filesystems/locking.rst +0 -3
@@ -488,9 +488,6 @@ getgeo: no swap_slot_free_notify: no (see below) ======================= =================== -unlock_native_capacity and revalidate_disk are called only from -check_disk_change(). - swap_slot_free_notify is called with swap_lock and sometimes the page lock held.
Signature · 1 line
2.28.0
Re: [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence
Looks good,
Christoph Hellwig
maintainerPATCH 2/9 block: don't clear bd_invalidated in check_disk_size_change
In reply to Christoph Hellwigbd_invalidated is set by check_disk_change or in add_disk to initiate a partition scan. Move it from check_disk_size_change which is called from both revalidate_disk() and bdev_disk_changed() to only the latter, as that is what is called from the block device open code (and nbd) to deal with the bd_invalidated event. revalidate_disk() on the other hand is mostly used to propagate a size update from the gendisk to the block device, which is entirely unrelated.
--- fs/block_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/block_dev.c +2 -1
@@ -1302,7 +1302,6 @@ static void check_disk_size_change(struct gendisk *disk, }i_size_write (bdev->bd_inode, disk_size); } - bdev->bd_invalidated =0 ;spin_unlock (&bdev->bd_size_lock);if (bdev_size > disk_size) {
@@ -1391,6 +1390,8 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)lockdep_assert_held (&bdev->bd_mutex); + bdev->bd_invalidated =0 ; + rescan: ret =blk_drop_partitions (bdev);if (ret)
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 3/9 block: rename bd_invalidated
In reply to Christoph HellwigReplace bd_invalidate with a new BDEV_NEED_PART_SCAN flag in a bd_flags variable to better describe the condition.
--- block/genhd.c | 2 +- drivers/block/nbd.c | 8 ++++---- fs/block_dev.c | 10 +++++----- include/linux/blk_types.h | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-)
block/genhd.c +1 -1
@@ -734,7 +734,7 @@ static void register_disk(struct device *parent, struct gendisk *disk,if (!bdev) goto exit; - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); err =blkdev_get (bdev,FMODE_READ ,NULL );if (err <0 ) goto exit;
drivers/block/nbd.c +4 -4
@@ -315,7 +315,7 @@ static void nbd_size_update(struct nbd_device *nbd)bd_set_nr_sectors (bdev, nr_sectors);set_blocksize (bdev, config->blksize); }else - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags);bdput (bdev); }kobject_uevent (&nbd_to_dev (nbd)->kobj,KOBJ_CHANGE );
@@ -1322,7 +1322,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *breturn ret;if (max_part) - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags);mutex_unlock (&nbd->config_lock); ret =wait_event_interruptible (config->recv_wq,atomic_read (&config->recv_threads) ==0 );
@@ -1500,9 +1500,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)refcount_set (&nbd->config_refs,1 );refcount_inc (&nbd->refs);mutex_unlock (&nbd->config_lock); - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); }else if (nbd_disconnected (nbd->config)) { - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); } out:mutex_unlock (&nbd_index_mutex);
fs/block_dev.c +5 -5
@@ -881,7 +881,7 @@ struct block_device *bdget(dev_t dev) bdev->bd_super =NULL ; bdev->bd_inode = inode; bdev->bd_part_count =0 ; - bdev->bd_invalidated =0 ; + bdev->bd_flags =0 ; inode->i_mode =S_IFBLK ; inode->i_rdev = dev; inode->i_bdev = bdev;
@@ -1365,7 +1365,7 @@ int check_disk_change(struct block_device *bdev)if (__invalidate_device (bdev, true))pr_warn ("VFS: busy inodes on changed media %s\n" , disk->disk_name); - bdev->bd_invalidated =1 ; +set_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags);if (bdops->revalidate_disk) bdops->revalidate_disk (bdev->bd_disk);return 1 ;
@@ -1390,7 +1390,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)lockdep_assert_held (&bdev->bd_mutex); - bdev->bd_invalidated =0 ; +clear_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags); rescan: ret =blk_drop_partitions (bdev);
@@ -1528,7 +1528,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,* The latter is necessary to prevent ghost * partitions on a removed medium. */ -if (bdev->bd_invalidated && +if (test_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags) && (!ret || ret == -ENOMEDIUM ))bdev_disk_changed (bdev, ret == -ENOMEDIUM );
@@ -1558,7 +1558,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,if (bdev->bd_disk->fops->open) ret = bdev->bd_disk->fops->open (bdev, mode);/* the same as first opener case, read comment there */ -if (bdev->bd_invalidated && +if (test_bit (BDEV_NEED_PART_SCAN , &bdev->bd_flags) && (!ret || ret == -ENOMEDIUM ))bdev_disk_changed (bdev, ret == -ENOMEDIUM );if (ret)
include/linux/blk_types.h +3 -1
@@ -19,6 +19,8 @@ struct cgroup_subsys_state;typedef void (bio_end_io_t ) (struct bio *);struct bio_crypt_ctx ; +#define BDEV_NEED_PART_SCAN 0 +struct block_device {dev_t bd_dev;/* not a kdev_t - it's a search key */ int bd_openers;
@@ -37,7 +39,7 @@ struct block_device {struct hd_struct * bd_part;/* number of times partitions within this device have been opened. */ unsigned bd_part_count; -int bd_invalidated; +unsigned long bd_flags;spinlock_t bd_size_lock;/* for bd_inode->i_size updates */ struct gendisk * bd_disk;struct backing_dev_info *bd_bdi;
Signature · 1 line
2.28.0
Re: [PATCH 3/9] block: rename bd_invalidated
Looks good,
Christoph Hellwig
maintainerPATCH 4/9 block: add a new revalidate_disk_size helper
In reply to Christoph Hellwigrevalidate_disk is a relative awkward helper for driver use, as it first calls an optional driver method and then updates the block device size, while most callers either don't need the method call at all, or want to keep state between the caller and the called method.
Add a revalidate_disk_size helper that just performs the update of the block device size from the gendisk one, and switch all drivers that do not implement ->revalidate_disk to use the new helper instead of revalidate_disk()
--- drivers/block/rbd.c | 2 +- drivers/block/rnbd/rnbd-clt.c | 10 ++------- drivers/block/virtio_blk.c | 2 +- drivers/block/zram/zram_drv.c | 4 ++-- drivers/md/dm-raid.c | 2 +- drivers/md/md-cluster.c | 6 ++--- drivers/md/md-linear.c | 2 +- drivers/md/md.c | 10 ++++----- fs/block_dev.c | 42 ++++++++++++++++++++++++----------- include/linux/genhd.h | 1 + 10 files changed, 46 insertions(+), 35 deletions(-)
drivers/block/rbd.c +1 -1
@@ -4921,7 +4921,7 @@ static void rbd_dev_update_size(struct rbd_device *rbd_dev) size = (sector_t )rbd_dev->mapping.size /SECTOR_SIZE ;dout ("setting size to %llu sectors" , (unsigned long long )size);set_capacity (rbd_dev->disk, size); -revalidate_disk (rbd_dev->disk); +revalidate_disk_size (rbd_dev->disk, true); } }
drivers/block/rnbd/rnbd-clt.c +2 -8
@@ -102,18 +102,12 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev,static int rnbd_clt_change_capacity (struct rnbd_clt_dev *dev,size_t new_nsectors) { -int err =0 ; -rnbd_clt_info (dev,"Device size changed from %zu to %zu sectors\n" , dev->nsectors, new_nsectors); dev->nsectors = new_nsectors;set_capacity (dev->gd, dev->nsectors); - err =revalidate_disk (dev->gd); -if (err) -rnbd_clt_err (dev, -"Failed to change device size from %zu to %zu, err: %d\n" , - dev->nsectors, new_nsectors, err); -return err; +revalidate_disk_size (dev->gd, true); +return 0 ; } static int process_msg_open_rsp(struct rnbd_clt_dev *dev,
drivers/block/virtio_blk.c +1 -1
@@ -598,7 +598,7 @@ static void virtblk_update_cache_mode(struct virtio_device *vdev)struct virtio_blk *vblk = vdev->priv;blk_queue_write_cache (vblk->disk->queue, writeback, false); -revalidate_disk (vblk->disk); +revalidate_disk_size (vblk->disk, true); }static const char *const virtblk_cache_types[] = {
drivers/block/zram/zram_drv.c +2 -2
@@ -1739,7 +1739,7 @@ static ssize_t disksize_store(struct device *dev, zram->disksize = disksize;set_capacity (zram->disk, zram->disksize >>SECTOR_SHIFT ); -revalidate_disk (zram->disk); +revalidate_disk_size (zram->disk, true);up_write (&zram->init_lock);return len;
@@ -1786,7 +1786,7 @@ static ssize_t reset_store(struct device *dev,/* Make sure all the pending I/O are finished */ fsync_bdev (bdev);zram_reset_device (zram); -revalidate_disk (zram->disk); +revalidate_disk_size (zram->disk, true);bdput (bdev);mutex_lock (&bdev->bd_mutex);
drivers/md/dm-raid.c +1 -1
@@ -701,7 +701,7 @@ static void rs_set_capacity(struct raid_set *rs)struct gendisk *gendisk =dm_disk (dm_table_get_md (rs->ti->table));set_capacity (gendisk, rs->md.array_sectors); -revalidate_disk (gendisk); +revalidate_disk_size (gendisk, true); }/*
drivers/md/md-cluster.c +3 -3
@@ -582,7 +582,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)break ;case CHANGE_CAPACITY :set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true);break ;case RESYNCING :set_bit (MD_RESYNCING_REMOTE , &mddev->recovery);
@@ -1296,12 +1296,12 @@ static void update_size(struct mddev *mddev, sector_t old_dev_sectors)pr_err ("%s:%d: failed to send CHANGE_CAPACITY msg\n" , __func__, __LINE__);set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true); }else {/* revert to previous sectors */ ret = mddev->pers->resize (mddev, old_dev_sectors);if (!ret) -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true); ret =__sendmsg (cinfo, &cmsg);if (ret) pr_err("%s:%d: failed to send METADATA_UPDATED msg\n",
drivers/md/md-linear.c +1 -1
@@ -202,7 +202,7 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)md_set_array_sectors (mddev,linear_size (mddev,0 ,0 ));set_capacity (mddev->gendisk, mddev->array_sectors);mddev_resume (mddev); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true);kfree_rcu (oldconf, rcu);return 0 ; }
drivers/md/md.c +5 -5
@@ -5358,7 +5358,7 @@ array_size_store(struct mddev *mddev, const char *buf, size_t len) mddev->array_sectors = sectors;if (mddev->pers) {set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true); } }mddev_unlock (mddev);
@@ -6109,7 +6109,7 @@ int do_md_run(struct mddev *mddev)md_wakeup_thread (mddev->sync_thread);/* possibly kick off a reshape */ set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true);clear_bit (MD_NOT_READY , &mddev->flags); mddev->changed =1 ;kobject_uevent (&disk_to_dev (mddev->gendisk)->kobj,KOBJ_CHANGE );
@@ -6427,7 +6427,7 @@ static int do_md_stop(struct mddev *mddev, int mode,set_capacity (disk,0 );mutex_unlock (&mddev->open_mutex); mddev->changed =1 ; -revalidate_disk (disk); +revalidate_disk_size (disk, true);if (mddev->ro) mddev->ro =0 ;
@@ -7259,7 +7259,7 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) md_cluster_ops->update_size (mddev, old_dev_sectors); else if (mddev->queue) {set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true); } }return rv;
@@ -9018,7 +9018,7 @@ void md_do_sync(struct md_thread *thread)mddev_unlock (mddev);if (!mddev_is_clustered (mddev)) {set_capacity (mddev->gendisk, mddev->array_sectors); -revalidate_disk (mddev->gendisk); +revalidate_disk_size (mddev->gendisk, true); } }
fs/block_dev.c +29 -13
54 lines not on this page · raw message
include/linux/genhd.h +1 -0
@@ -373,6 +373,7 @@ int register_blkdev(unsigned int major, const char *name);void unregister_blkdev (unsigned int major,const char *name);int revalidate_disk (struct gendisk *disk); +void revalidate_disk_size (struct gendisk *disk,bool verbose);int check_disk_change (struct block_device *bdev);int __invalidate_device (struct block_device *bdev,bool kill_dirty);void bd_set_nr_sectors (struct block_device *bdev,sector_t sectors);
Signature · 1 line
2.28.0
Re: [PATCH 4/9] block: add a new revalidate_disk_size helper
Quoted 1 line · Christoph Hellwig
[...]
Quoted 3 lines
drivers/md/md-cluster.c | 6 ++--- drivers/md/md-linear.c | 2 +- drivers/md/md.c | 10 ++++-----
For md bits:
[...]
Quoted 18 lines
fs/block_dev.c +17
-0+/** +* revalidate_disk_size - checks for disk size change and adjusts bdev size. +* @disk: struct gendisk to check +* @verbose: if %true log a message about a size change if there is any +* +* This routine checks to see if the bdev size does not match the disk size +* and adjusts it if it differs. When shrinking the bdev size, its all caches +* are freed. +*/ +void revalidate_disk_size (struct gendisk *disk,bool verbose) +{ +struct block_device *bdev; + +/* +* Hidden disks don't have associated bdev so there's no point in +* revalidating them. +*/
fs/block_dev.c static void check_disk_size_change(struct gendisk *disk, · line 1340
Quoted 10 lines
fs/block_dev.c +10
-0+if (disk->flags &GENHD_FL_HIDDEN ) +return ; + + bdev =bdget_disk (disk,0 ); +if (bdev) { +check_disk_size_change (disk, bdev, verbose); +bdput (bdev); + } +} +EXPORT_SYMBOL (revalidate_disk_size);
Shall we use EXPORT_SYMBOL_GPL() here?
[...]
Re: [PATCH 4/9] block: add a new revalidate_disk_size helper
In reply to Christoph HellwigLooks good,
Christoph Hellwig
maintainerPATCH 5/9 block: use revalidate_disk_size in set_capacity_revalidate_and_notify
In reply to Christoph HellwigOnly virtio_blk and xen-blkfront set the revalidate argument to true, and both do not implement the ->revalidate_disk method. So switch to the helper that just updates the size instead.
--- block/genhd.c | 7 +++---- include/linux/genhd.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)
block/genhd.c +3 -4
@@ -50,14 +50,13 @@ static void disk_release_events(struct gendisk *disk);* zero and will not be set to zero */ void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, -bool revalidate) +bool update_bdev) {sector_t capacity =get_capacity (disk);set_capacity (disk, size); - -if (revalidate) -revalidate_disk (disk); +if (update_bdev) +revalidate_disk_size (disk, true);if (capacity != size && capacity !=0 && size !=0 ) {char *envp[] = {"RESIZE=1" ,NULL };
include/linux/genhd.h +2 -2
@@ -315,8 +315,8 @@ static inline int get_disk_ro(struct gendisk *disk)extern void disk_block_events (struct gendisk *disk);extern void disk_unblock_events (struct gendisk *disk);extern void disk_flush_events (struct gendisk *disk,unsigned int mask); -extern void set_capacity_revalidate_and_notify (struct gendisk *disk, -sector_t size,bool revalidate); +void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, +bool update_bdev);extern unsigned int disk_clear_events (struct gendisk *disk,unsigned int mask);/* drivers/char/random.c */
Signature · 1 line
2.28.0
Re: [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify
Looks good,
Christoph Hellwig
maintainerPATCH 6/9 nvme: opencode revalidate_disk in nvme_validate_ns
In reply to Christoph HellwigKeep control in the NVMe driver instead of going through an indirect call back into ->revalidate_disk. Also reorder the function a bit to be easier to follow with the additional code.
And now that we have removed all callers of revalidate_disk() in the nvme code, ->revalidate_disk is only called from the open code when first opening the device. Which is of course totally pointless as we have a valid size since the initial scan, and will get an updated view through the asynchronous notifiation everytime the size changes.
--- drivers/nvme/host/core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +10 -6
@@ -2323,7 +2323,6 @@ static const struct block_device_operations nvme_fops = { .open = nvme_open, .release = nvme_release, .getgeo = nvme_getgeo, - .revalidate_disk= nvme_revalidate_disk, .report_zones = nvme_report_zones, .pr_ops = &nvme_pr_ops, };
@@ -4020,14 +4019,19 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)static void nvme_validate_ns (struct nvme_ctrl *ctrl,unsigned nsid) {struct nvme_ns *ns; +int ret; ns =nvme_find_get_ns (ctrl, nsid); -if (ns) { -if (revalidate_disk (ns->disk)) -nvme_ns_remove (ns); -nvme_put_ns (ns); - }else +if (!ns) {nvme_alloc_ns (ctrl, nsid); +return ; + } + + ret =nvme_revalidate_disk (ns->disk); +revalidate_disk_size (ns->disk, ret ==0 ); +if (ret) +nvme_ns_remove (ns); +nvme_put_ns (ns); } static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
Signature · 1 line
2.28.0
Re: [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns
Looks good,
Christoph Hellwig
maintainerPATCH 7/9 sd: open code revalidate_disk
In reply to Christoph HellwigInstead of calling revalidate_disk just do the work directly by calling sd_revalidate_disk, and revalidate_disk_size where needed.
--- drivers/scsi/sd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +4 -2
@@ -217,7 +217,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,sd_print_sense_hdr (sdkp, &sshdr);return -EINVAL ; } -revalidate_disk (sdkp->disk); +sd_revalidate_disk (sdkp->disk);return count; }
@@ -1706,8 +1706,10 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)static void sd_rescan (struct device *dev) {struct scsi_disk *sdkp =dev_get_drvdata (dev); +int ret; -revalidate_disk (sdkp->disk); + ret =sd_revalidate_disk (sdkp->disk); +revalidate_disk_size (sdkp->disk, ret ==0 ); } static int sd_ioctl(struct block_device *bdev, fmode_t mode,
Signature · 1 line
2.28.0
Re: [PATCH 7/9] sd: open code revalidate_disk
Looks good,
Christoph Hellwig
maintainerPATCH 8/9 nvdimm: simplify revalidate_disk handling
In reply to Christoph HellwigThe nvdimm block driver abuse revalidate_disk in a strange way, and totally unrelated to what other drivers do. Simplify this by just calling nvdimm_revalidate_disk (which seems rather misnamed) from the probe routines, as the additional bdev size revalidation is pointless at this point, and remove the revalidate_disk methods given that it can only be triggered from add_disk, which is right before the manual calls.
--- drivers/nvdimm/blk.c | 3 +-- drivers/nvdimm/btt.c | 3 +-- drivers/nvdimm/bus.c | 9 +++------ drivers/nvdimm/nd.h | 2 +- drivers/nvdimm/pmem.c | 3 +-- 5 files changed, 7 insertions(+), 13 deletions(-)
drivers/nvdimm/blk.c +1 -2
@@ -226,7 +226,6 @@ static int nsblk_rw_bytes(struct nd_namespace_common *ndns,static const struct block_device_operations nd_blk_fops = { .owner =THIS_MODULE , .submit_bio = nd_blk_submit_bio, - .revalidate_disk = nvdimm_revalidate_disk, };static void nd_blk_release_queue (void *q)
@@ -284,7 +283,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)set_capacity (disk, available_disk_size >>SECTOR_SHIFT );device_add_disk (dev, disk,NULL ); -revalidate_disk (disk); +nvdimm_check_and_set_ro (disk);return 0 ; }
drivers/nvdimm/btt.c +1 -2
@@ -1513,7 +1513,6 @@ static const struct block_device_operations btt_fops = { .submit_bio = btt_submit_bio, .rw_page = btt_rw_page, .getgeo = btt_getgeo, - .revalidate_disk = nvdimm_revalidate_disk, };static int btt_blk_init (struct btt *btt)
@@ -1558,7 +1557,7 @@ static int btt_blk_init(struct btt *btt)set_capacity (btt->btt_disk, btt->nlba * btt->sector_size >>9 );device_add_disk (&btt->nd_btt->dev, btt->btt_disk,NULL ); btt->nd_btt->size = btt->nlba * (u64 )btt->sector_size; -revalidate_disk (btt->btt_disk); +nvdimm_check_and_set_ro (btt->btt_disk);return 0 ; }
drivers/nvdimm/bus.c +3 -6
@@ -628,7 +628,7 @@ int __nd_driver_register(struct nd_device_driver *nd_drv, struct module *owner, }EXPORT_SYMBOL (__nd_driver_register); -int nvdimm_revalidate_disk (struct gendisk *disk) +void nvdimm_check_and_set_ro (struct gendisk *disk) {struct device *dev =disk_to_dev (disk)->parent;struct nd_region *nd_region =to_nd_region (dev->parent);
@@ -639,16 +639,13 @@ int nvdimm_revalidate_disk(struct gendisk *disk)* read-only if the disk is already read-only. */ if (disk_ro || nd_region->ro == disk_ro) -return 0 ; +return ;dev_info (dev,"%s read-only, marking %s read-only\n" ,dev_name (&nd_region->dev), disk->disk_name);set_disk_ro (disk,1 ); - -return 0 ; - } -EXPORT_SYMBOL (nvdimm_revalidate_disk); +EXPORT_SYMBOL (nvdimm_check_and_set_ro);static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf)
drivers/nvdimm/nd.h +1 -1
@@ -361,7 +361,7 @@ u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region);void nvdimm_bus_lock (struct device *dev);void nvdimm_bus_unlock (struct device *dev);bool is_nvdimm_bus_locked (struct device *dev); -int nvdimm_revalidate_disk (struct gendisk *disk); +void nvdimm_check_and_set_ro (struct gendisk *disk);void nvdimm_drvdata_release (struct kref *kref);void put_ndd (struct nvdimm_drvdata *ndd);int nd_label_reserve_dpa (struct nvdimm_drvdata *ndd);
drivers/nvdimm/pmem.c +1 -2
@@ -281,7 +281,6 @@ static const struct block_device_operations pmem_fops = { .owner = THIS_MODULE, .submit_bio = pmem_submit_bio, .rw_page = pmem_rw_page, - .revalidate_disk = nvdimm_revalidate_disk, }; static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
@@ -501,7 +500,7 @@ static int pmem_attach_disk(struct device *dev,if (devm_add_action_or_reset (dev, pmem_release_disk, pmem))return -ENOMEM ; -revalidate_disk (disk); +nvdimm_check_and_set_ro (disk); pmem->bb_state =sysfs_get_dirent (disk_to_dev (disk)->kobj.sd,"badblocks" );
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 9/9 block: remove revalidate_disk()
In reply to Christoph HellwigRemove the now unused helper.
--- drivers/md/md.h | 2 +- fs/block_dev.c | 19 ------------------- include/linux/genhd.h | 1 - 3 files changed, 1 insertion(+), 21 deletions(-)
drivers/md/md.h +1 -1
@@ -397,7 +397,7 @@ struct mddev {* These locks are separate due to conflicting interactions * with bdev->bd_mutex. * Lock ordering is: -* reconfig_mutex -> bd_mutex : e.g. do_md_run -> revalidate_disk +* reconfig_mutex -> bd_mutex * bd_mutex -> open_mutex: e.g. __blkdev_get -> md_open */ struct mutex open_mutex;
fs/block_dev.c +0 -19
@@ -1339,25 +1339,6 @@ void revalidate_disk_size(struct gendisk *disk, bool verbose) }EXPORT_SYMBOL (revalidate_disk_size); -/** -* revalidate_disk - wrapper for lower-level driver's revalidate_disk call-back -* @disk: struct gendisk to be revalidated -* -* This routine is a wrapper for lower-level driver's revalidate_disk -* call-backs. It is used to do common pre and post operations needed -* for all revalidate_disk operations. -*/ -int revalidate_disk (struct gendisk *disk) -{ -int ret =0 ; - -if (disk->fops->revalidate_disk) - ret = disk->fops->revalidate_disk (disk); -revalidate_disk_size (disk, ret ==0 ); -return ret; -} -EXPORT_SYMBOL (revalidate_disk); -/* * This routine checks whether a removable media has been changed, * and invalidates all buffer-cache-entries in that case. This
include/linux/genhd.h +0 -1
@@ -372,7 +372,6 @@ extern void blk_unregister_region(dev_t devt, unsigned long range);int register_blkdev (unsigned int major,const char *name);void unregister_blkdev (unsigned int major,const char *name); -int revalidate_disk (struct gendisk *disk);void revalidate_disk_size (struct gendisk *disk,bool verbose);int check_disk_change (struct block_device *bdev);int __invalidate_device (struct block_device *bdev,bool kill_dirty);
Signature · 1 line
2.28.0
Re: [PATCH 9/9] block: remove revalidate_disk()
Quoted 4 lines · Christoph Hellwig
Remove the now unused helper.
Signed-off-by Christoph Hellwig <[email protected]>
Re: [PATCH 9/9] block: remove revalidate_disk()
In reply to Christoph HellwigLooks good,
Quoted 12 lines · Christoph Hellwig
Hi Jens,
this series removes the
revalidate_disk()function, which has been a really odd duck in the last years. The prime reason why most people use it is because it propagates a size change from the gendisk to theblock_devicestructure. But it also calls into the rather ill defined ->revalidate_disk method which is rather useless for the callers. So this adds a new helper to just propagate the size, and cleans up all kinds of mess around this area. Follow on patches will eventuall kill of ->revalidate_disk entirely, but ther are a lot more patches needed for that.
I applied and built everything on Jens's for-next, patch #2 was fuzzy but it applied.
I checked through everything, the only thing that was strange to me is not calling revalidate_disk_size() in nvdimm, but since it's during attach you point out it doesn't matter. You can add
To the series, thanks,
Josef
Quoted 11 lines · Christoph Hellwig
Hi Jens,
this series removes the
revalidate_disk()function, which has been a really odd duck in the last years. The prime reason why most people use it is because it propagates a size change from the gendisk to theblock_devicestructure. But it also calls into the rather ill defined ->revalidate_disk method which is rather useless for the callers. So this adds a new helper to just propagate the size, and cleans up all kinds of mess around this area. Follow on patches will eventuall kill of ->revalidate_disk entirely, but ther are a lot more patches needed for that.
Applied, thanks.
Signature · 1 line
Jens Axboe