rbd: have rbd_dev_image_id() set format 1 image id
authorAlex Elder <elder@inktank.com>
Fri, 26 Apr 2013 04:15:08 +0000 (23:15 -0500)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:19:33 +0000 (21:19 -0700)
commitc0fba36880288afbeca872298c970fb4abb76464
treef5412ef5ae75e500239e25fbb865a24ced15f27a
parenta0cab924324fac8d6414009bc25ce31eeece038e
rbd: have rbd_dev_image_id() set format 1 image id

Currently, rbd_dev_probe() assumes that any error returned by
rbd_dev_image_id() is most likely -ENOENT, and responds by
calling the format 1 probe routine, rbd_dev_v1_probe().  Then,
at the top of rbd_dev_v1_probe(), an empty string is allocated
for the image id.

This is sort of unbalanced.  Fix this by having rbd_dev_image_id()
look for -ENOENT from its "get_id" method call.  If that is seen,
have it allocate the empty string there rather than depending on
rbd_dev_v1_probe() to do it.

Given that this is effectively defining the format of the image,
set rbd_dev->image_format inside rbd_dev_image_id() rather than in
the format-specific probe routines.

Also drop a redundant hunk of code in rbd_dev_image_id().

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c