nvdimm: simplify revalidate_disk handling
authorChristoph Hellwig <hch@lst.de>
Tue, 1 Sep 2020 15:57:47 +0000 (17:57 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 2 Sep 2020 14:00:07 +0000 (08:00 -0600)
The 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvdimm/blk.c
drivers/nvdimm/btt.c
drivers/nvdimm/bus.c
drivers/nvdimm/nd.h
drivers/nvdimm/pmem.c

index 1f718381a04553c5840e51d96b721d62d7cb56a9..22e5617b2cea14d94ce66819d04f1fe4c9cf0039 100644 (file)
@@ -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;
 }
 
index 0ff610e728ff6f3ea3d1fedb49a9b5c735aff6a5..0d710140bf93be8921a0a61586785150bcc999e6 100644 (file)
@@ -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;
 }
index 955265656b96c730db22ddaf8e527a7509cf329a..2304c6183822e9b2ee71b7bcc4ee46ce3a7b1359 100644 (file)
@@ -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)
index 85c1ae813ea318857a2f7e281a0dd9f3a91ae3dd..72740108ba4206b7407f56134d2b1b141954e4f0 100644 (file)
@@ -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);
index fab29b514372d069150688241fe77c8ef1edea2f..140cf3b9000c60d832b2c26ccbf6c7ff64992ba4 100644 (file)
@@ -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");