aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-07-23 09:11:19 -0400
committerIlya Dryomov <ilya.dryomov@inktank.com>2014-07-25 05:15:00 -0400
commita720ae0901eddab5c94a17402b7ed29e1afb5003 (patch)
tree759f327e7d8f9b5a2c6ef358bbcf9d8639e849a2 /drivers/block/rbd.c
parentff96128fb020e26e7b32e12e887013956d840f08 (diff)
rbd: introduce rbd_dev_header_info()
A wrapper around rbd_dev_v{1,2}_header_info() to reduce duplication. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7847fbb949ff..0d3be608f16f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -514,7 +514,7 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev);
514 514
515static int rbd_dev_refresh(struct rbd_device *rbd_dev); 515static int rbd_dev_refresh(struct rbd_device *rbd_dev);
516static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev); 516static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev);
517static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev); 517static int rbd_dev_header_info(struct rbd_device *rbd_dev);
518static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, 518static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,
519 u64 snap_id); 519 u64 snap_id);
520static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id, 520static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
@@ -3506,13 +3506,10 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)
3506 u64 mapping_size; 3506 u64 mapping_size;
3507 int ret; 3507 int ret;
3508 3508
3509 rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
3510 down_write(&rbd_dev->header_rwsem); 3509 down_write(&rbd_dev->header_rwsem);
3511 mapping_size = rbd_dev->mapping.size; 3510 mapping_size = rbd_dev->mapping.size;
3512 if (rbd_dev->image_format == 1) 3511
3513 ret = rbd_dev_v1_header_info(rbd_dev); 3512 ret = rbd_dev_header_info(rbd_dev);
3514 else
3515 ret = rbd_dev_v2_header_info(rbd_dev);
3516 3513
3517 /* If it's a mapped snapshot, validate its EXISTS flag */ 3514 /* If it's a mapped snapshot, validate its EXISTS flag */
3518 3515
@@ -4501,6 +4498,16 @@ static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev)
4501 return ret; 4498 return ret;
4502} 4499}
4503 4500
4501static int rbd_dev_header_info(struct rbd_device *rbd_dev)
4502{
4503 rbd_assert(rbd_image_format_valid(rbd_dev->image_format));
4504
4505 if (rbd_dev->image_format == 1)
4506 return rbd_dev_v1_header_info(rbd_dev);
4507
4508 return rbd_dev_v2_header_info(rbd_dev);
4509}
4510
4504static int rbd_bus_add_dev(struct rbd_device *rbd_dev) 4511static int rbd_bus_add_dev(struct rbd_device *rbd_dev)
4505{ 4512{
4506 struct device *dev; 4513 struct device *dev;
@@ -5149,10 +5156,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
5149 goto out_header_name; 5156 goto out_header_name;
5150 } 5157 }
5151 5158
5152 if (rbd_dev->image_format == 1) 5159 ret = rbd_dev_header_info(rbd_dev);
5153 ret = rbd_dev_v1_header_info(rbd_dev);
5154 else
5155 ret = rbd_dev_v2_header_info(rbd_dev);
5156 if (ret) 5160 if (ret)
5157 goto err_out_watch; 5161 goto err_out_watch;
5158 5162