Commit da5ef6be authored by Ilya Dryomov's avatar Ilya Dryomov

rbd: call rbd_dev_mapping_set() from rbd_dev_image_probe()

Snapshot object map will be loaded in rbd_dev_image_probe(), so we need
to know snapshot's size (as opposed to HEAD's size) sooner.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
parent 4cf3e6df
...@@ -6018,6 +6018,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev) ...@@ -6018,6 +6018,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev)
struct rbd_image_header *header; struct rbd_image_header *header;
rbd_dev_parent_put(rbd_dev); rbd_dev_parent_put(rbd_dev);
rbd_dev_mapping_clear(rbd_dev);
/* Free dynamic fields from the header, then zero it out */ /* Free dynamic fields from the header, then zero it out */
...@@ -6118,7 +6119,6 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) ...@@ -6118,7 +6119,6 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
static void rbd_dev_device_release(struct rbd_device *rbd_dev) static void rbd_dev_device_release(struct rbd_device *rbd_dev)
{ {
clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
rbd_dev_mapping_clear(rbd_dev);
rbd_free_disk(rbd_dev); rbd_free_disk(rbd_dev);
if (!single_major) if (!single_major)
unregister_blkdev(rbd_dev->major, rbd_dev->name); unregister_blkdev(rbd_dev->major, rbd_dev->name);
...@@ -6152,23 +6152,17 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) ...@@ -6152,23 +6152,17 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
if (ret) if (ret)
goto err_out_blkdev; goto err_out_blkdev;
ret = rbd_dev_mapping_set(rbd_dev);
if (ret)
goto err_out_disk;
set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only); set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only);
ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id); ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id);
if (ret) if (ret)
goto err_out_mapping; goto err_out_disk;
set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
up_write(&rbd_dev->header_rwsem); up_write(&rbd_dev->header_rwsem);
return 0; return 0;
err_out_mapping:
rbd_dev_mapping_clear(rbd_dev);
err_out_disk: err_out_disk:
rbd_free_disk(rbd_dev); rbd_free_disk(rbd_dev);
err_out_blkdev: err_out_blkdev:
...@@ -6269,6 +6263,10 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth) ...@@ -6269,6 +6263,10 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
goto err_out_probe; goto err_out_probe;
} }
ret = rbd_dev_mapping_set(rbd_dev);
if (ret)
goto err_out_probe;
if (rbd_dev->header.features & RBD_FEATURE_LAYERING) { if (rbd_dev->header.features & RBD_FEATURE_LAYERING) {
ret = rbd_dev_v2_parent_info(rbd_dev); ret = rbd_dev_v2_parent_info(rbd_dev);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment