Merge pull request #20406 from dillaman/wip-22979

librbd: fix issues discovered in clone v2 during upgrade tests

Reviewed-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
Mykola Golub 2018-02-14 09:36:02 +02:00 committed by GitHub
commit ad765021bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -2002,8 +2002,15 @@ int snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
return r;
}
cls_rbd_parent parent;
r = read_key(hctx, "parent", &parent);
if (r < 0 && r != -ENOENT) {
return r;
}
bool has_parent = (r >= 0 && parent.pool != -1);
uint64_t op_features_mask = 0ULL;
if (!has_child_snaps) {
if (!has_child_snaps && !has_parent) {
// disable clone child op feature if no longer associated
op_features_mask |= RBD_OPERATION_FEATURE_CLONE_CHILD;
}

View File

@ -1041,8 +1041,10 @@ class TestClone(object):
self.image.create_snap('snap2')
global features
clone_name2 = get_temp_image_name()
rados.conf_set("rbd_default_clone_format", "1")
assert_raises(InvalidArgument, self.rbd.clone, ioctx, image_name,
'snap2', ioctx, clone_name2, features)
rados.conf_set("rbd_default_clone_format", "auto")
self.image.remove_snap('snap2')
def test_unprotect_with_children(self):
@ -1065,8 +1067,10 @@ class TestClone(object):
# ...with a clone of the same parent
other_clone_name = get_temp_image_name()
rados.conf_set("rbd_default_clone_format", "1")
self.rbd.clone(ioctx, image_name, 'snap1', other_ioctx,
other_clone_name, features)
rados.conf_set("rbd_default_clone_format", "auto")
self.other_clone = Image(other_ioctx, other_clone_name)
# validate its parent info
(pool, image, snap) = self.other_clone.parent_info()