Commit cf32bd9c authored by Ilya Dryomov's avatar Ilya Dryomov Committed by Ilya Dryomov

rbd: do not treat standalone as flatten

If the clone is resized down to 0, it becomes standalone.  If such
resize is carried over while an image is mapped we would detect this
and call rbd_dev_parent_put() which means "let go of all parent state,
including the spec(s) of parent images(s)".  This leads to a mismatch
between "rbd info" and sysfs parent fields, so a fix is in order.

    # rbd create --image-format 2 --size 1 foo
    # rbd snap create foo@snap
    # rbd snap protect foo@snap
    # rbd clone foo@snap bar
    # DEV=$(rbd map bar)
    # rbd resize --allow-shrink --size 0 bar
    # rbd resize --size 1 bar
    # rbd info bar | grep parent
            parent: rbd/foo@snap

Before:

    # cat /sys/bus/rbd/devices/0/parent
    (no parent image)

After:

    # cat /sys/bus/rbd/devices/0/parent
    pool_id 0
    pool_name rbd
    image_id 10056b8b4567
    image_name foo
    snap_id 2
    snap_name snap
    overlap 0
Signed-off-by: default avatarIlya Dryomov <idryomov@redhat.com>
Reviewed-by: default avatarJosh Durgin <jdurgin@redhat.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent bf91c315
...@@ -4273,32 +4273,22 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) ...@@ -4273,32 +4273,22 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
} }
/* /*
* We always update the parent overlap. If it's zero we * We always update the parent overlap. If it's zero we issue
* treat it specially. * a warning, as we will proceed as if there was no parent.
*/ */
rbd_dev->parent_overlap = overlap;
if (!overlap) { if (!overlap) {
/* A null parent_spec indicates it's the initial probe */
if (parent_spec) { if (parent_spec) {
/* /* refresh, careful to warn just once */
* The overlap has become zero, so the clone if (rbd_dev->parent_overlap)
* must have been resized down to 0 at some rbd_warn(rbd_dev,
* point. Treat this the same as a flatten. "clone now standalone (overlap became 0)");
*/
rbd_dev_parent_put(rbd_dev);
pr_info("%s: clone image now standalone\n",
rbd_dev->disk->disk_name);
} else { } else {
/* /* initial probe */
* For the initial probe, if we find the rbd_warn(rbd_dev, "clone is standalone (overlap 0)");
* overlap is zero we just pretend there was
* no parent image.
*/
rbd_warn(rbd_dev, "ignoring parent with overlap 0");
} }
} }
rbd_dev->parent_overlap = overlap;
out: out:
ret = 0; ret = 0;
out_err: out_err:
......
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