aboutsummaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-05-06 09:51:30 -0500
committerAlex Elder <elder@inktank.com>2013-05-08 17:00:41 -0500
commit30d60ba2f258da24b91edb880338c7178f901de9 (patch)
treeb0b39018e786a342da043517005e0201711053f3 /drivers/block
parent662518b128c27def65e9af4bea2b56a1e04b3251 (diff)
rbd: simplify rbd_dev_v1_probe()
An rbd_dev structure's fields are all zero-filled for an initial probe, so there's no need to explicitly zero the parent_spec and parent_overlap fields in rbd_dev_v1_probe(). Removing these assignments makes rbd_dev_v1_probe() *almost* trivial. Move the dout() message that announces discovery of an image into rbd_dev_image_probe(), generalize to support images in either format and only show it if an image is fully discovered. This highlights that are some unnecessary cleanups in the error path for rbd_dev_v1_probe(), so they can be removed. Now rbd_dev_v1_probe() *is* a trivial wrapper function. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e4586f2e04c..ae223819bbf 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4469,31 +4469,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev)
static int rbd_dev_v1_probe(struct rbd_device *rbd_dev)
{
- int ret;
-
- /* Populate rbd image metadata */
-
- ret = rbd_dev_v1_header_read(rbd_dev);
- if (ret < 0)
- goto out_err;
-
- /* Version 1 images have no parent (no layering) */
-
- rbd_dev->parent_spec = NULL;
- rbd_dev->parent_overlap = 0;
-
- dout("discovered version 1 image, header name is %s\n",
- rbd_dev->header_name);
-
- return 0;
-
-out_err:
- kfree(rbd_dev->header_name);
- rbd_dev->header_name = NULL;
- kfree(rbd_dev->spec->image_id);
- rbd_dev->spec->image_id = NULL;
-
- return ret;
+ return rbd_dev_v1_header_read(rbd_dev);
}
static int rbd_dev_v2_probe(struct rbd_device *rbd_dev)
@@ -4553,9 +4529,6 @@ static int rbd_dev_v2_probe(struct rbd_device *rbd_dev)
if (ret)
goto out_err;
- dout("discovered version 2 image, header name is %s\n",
- rbd_dev->header_name);
-
return 0;
out_err:
rbd_dev->parent_overlap = 0;
@@ -4758,9 +4731,13 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only)
rbd_dev->mapping.read_only = read_only;
ret = rbd_dev_probe_parent(rbd_dev);
- if (!ret)
- return 0;
+ if (ret)
+ goto err_out_probe;
+
+ dout("discovered format %u image, header name is %s\n",
+ rbd_dev->image_format, rbd_dev->header_name);
+ return 0;
err_out_probe:
rbd_dev_unprobe(rbd_dev);
err_out_watch: