mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 23:34:05 +08:00
nvdimm: simplify revalidate_disk handling
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>
This commit is contained in:
parent
033a1b98b1
commit
32f61d6757
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user