(unsigned long long)snap_id.val);
return -EIO;
}
- if (snap_meta.name == old_meta.name || snap_meta.id == old_meta.id) {
+ if ((snap_meta.name == old_meta.name &&
+ snap_meta.snapshot_namespace == old_meta.snapshot_namespace) ||
+ snap_meta.id == old_meta.id) {
CLS_LOG(20, "snap_name %s or snap_id %llu matches existing snap %s %llu",
snap_meta.name.c_str(), (unsigned long long)snap_meta.id.val,
old_meta.name.c_str(), (unsigned long long)old_meta.id.val);
TEST_F(TestClsRbd, snapshots_namespaces)
{
cls::rbd::SnapshotNamespace groupSnapNamespace = cls::rbd::GroupSnapshotNamespace(5, "1018643c9869", 3);
+ cls::rbd::SnapshotNamespace userSnapNamespace = cls::rbd::UserSnapshotNamespace();
librados::IoCtx ioctx;
ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx));
ASSERT_EQ(0, snapshot_add(&ioctx, oid, 0, "snap1"));
librados::ObjectWriteOperation op;
- ::librbd::cls_client::snapshot_add(&op, 0, "snap1", groupSnapNamespace);
+ ::librbd::cls_client::snapshot_add(&op, 1, "snap1", groupSnapNamespace);
int r = ioctx.operate(oid, &op);
ASSERT_EQ(0, r);
ASSERT_EQ(0, get_snapcontext(&ioctx, oid, &snapc));
- ASSERT_EQ(1u, snapc.snaps.size());
- ASSERT_EQ(0u, snapc.snaps[0]);
- ASSERT_EQ(0u, snapc.seq);
+ ASSERT_EQ(2u, snapc.snaps.size());
+ ASSERT_EQ(1u, snapc.snaps[0]);
+ ASSERT_EQ(0u, snapc.snaps[1]);
+ ASSERT_EQ(1u, snapc.seq);
ASSERT_EQ(0, snap_namespace_list(&ioctx, oid, snapc.snaps, &snap_namespaces));
ASSERT_EQ(groupSnapNamespace, snap_namespaces[0]);
+ ASSERT_EQ(userSnapNamespace, snap_namespaces[1]);
}
TEST_F(TestClsRbd, snapid_race)