Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librbd: fix issues discovered in clone v2 during upgrade tests #20406

Merged
merged 2 commits into from Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cls/rbd/cls_rbd.cc
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/pybind/test_rbd.py
Expand Up @@ -1041,8 +1041,10 @@ def test_unprotected(self):
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):
Expand All @@ -1065,8 +1067,10 @@ def test_unprotect_with_children(self):

# ...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()
Expand Down