aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2019-06-17 09:29:49 -0400
committerIlya Dryomov <idryomov@gmail.com>2019-07-08 08:01:45 -0400
commitda5ef6be3467eb2d293790dea69b5b562490715a (patch)
tree082215dda36b1b42ebf763a664cb1836dcae482b
parent4cf3e6dff7ea517544e1da7810a0b3ebba380d2c (diff)
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: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
-rw-r--r--drivers/block/rbd.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f0814c148b1c..3d861d3013f8 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6018,6 +6018,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev)
6018 struct rbd_image_header *header; 6018 struct rbd_image_header *header;
6019 6019
6020 rbd_dev_parent_put(rbd_dev); 6020 rbd_dev_parent_put(rbd_dev);
6021 rbd_dev_mapping_clear(rbd_dev);
6021 6022
6022 /* Free dynamic fields from the header, then zero it out */ 6023 /* Free dynamic fields from the header, then zero it out */
6023 6024
@@ -6118,7 +6119,6 @@ out_err:
6118static void rbd_dev_device_release(struct rbd_device *rbd_dev) 6119static void rbd_dev_device_release(struct rbd_device *rbd_dev)
6119{ 6120{
6120 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 6121 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
6121 rbd_dev_mapping_clear(rbd_dev);
6122 rbd_free_disk(rbd_dev); 6122 rbd_free_disk(rbd_dev);
6123 if (!single_major) 6123 if (!single_major)
6124 unregister_blkdev(rbd_dev->major, rbd_dev->name); 6124 unregister_blkdev(rbd_dev->major, rbd_dev->name);
@@ -6152,23 +6152,17 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
6152 if (ret) 6152 if (ret)
6153 goto err_out_blkdev; 6153 goto err_out_blkdev;
6154 6154
6155 ret = rbd_dev_mapping_set(rbd_dev);
6156 if (ret)
6157 goto err_out_disk;
6158
6159 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 6155 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
6160 set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only); 6156 set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only);
6161 6157
6162 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id); 6158 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id);
6163 if (ret) 6159 if (ret)
6164 goto err_out_mapping; 6160 goto err_out_disk;
6165 6161
6166 set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 6162 set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
6167 up_write(&rbd_dev->header_rwsem); 6163 up_write(&rbd_dev->header_rwsem);
6168 return 0; 6164 return 0;
6169 6165
6170err_out_mapping:
6171 rbd_dev_mapping_clear(rbd_dev);
6172err_out_disk: 6166err_out_disk:
6173 rbd_free_disk(rbd_dev); 6167 rbd_free_disk(rbd_dev);
6174err_out_blkdev: 6168err_out_blkdev:
@@ -6269,6 +6263,10 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
6269 goto err_out_probe; 6263 goto err_out_probe;
6270 } 6264 }
6271 6265
6266 ret = rbd_dev_mapping_set(rbd_dev);
6267 if (ret)
6268 goto err_out_probe;
6269
6272 if (rbd_dev->header.features & RBD_FEATURE_LAYERING) { 6270 if (rbd_dev->header.features & RBD_FEATURE_LAYERING) {
6273 ret = rbd_dev_v2_parent_info(rbd_dev); 6271 ret = rbd_dev_v2_parent_info(rbd_dev);
6274 if (ret) 6272 if (ret)