From 5acb020e978145dd64bd56bdb61696571b204b35 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Tue, 16 Feb 2021 14:42:44 +0900 Subject: [PATCH] osd, test: wait if the snapshot is deleting After calling selfmanaged_snap_remove, we don't know when trimming snapshot is finished. So, we make the OSD to return EBUSY if the snapshot in removed_snap_queue, then the unit test waits the completion Signed-off-by: Myoungwon Oh (cherry-picked from commit d6f9f23012b9ac133e767bd07a804707ba2207ef) --- src/osd/PrimaryLogPG.cc | 4 ++++ src/test/librados/tier_cxx.cc | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 2fa3c40f91f18..e639ca299b9ae 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3347,6 +3347,7 @@ int PrimaryLogPG::get_manifest_ref_count(ObjectContextRef obc, std::string& fp_o } // snap SnapSet& ss = obc->ssc->snapset; + const OSDMapRef& osdmap = get_osdmap(); for (vector::const_reverse_iterator p = ss.clones.rbegin(); p != ss.clones.rend(); ++p) { @@ -3355,6 +3356,9 @@ int PrimaryLogPG::get_manifest_ref_count(ObjectContextRef obc, std::string& fp_o ObjectContextRef obc_g = nullptr; hobject_t clone_oid = obc->obs.oi.soid; clone_oid.snap = *p; + if (osdmap->in_removed_snaps_queue(info.pgid.pgid.pool(), *p)) { + return -EBUSY; + } ObjectContextRef clone_obc = get_object_context(clone_oid, false); if (!clone_obc) { break; diff --git a/src/test/librados/tier_cxx.cc b/src/test/librados/tier_cxx.cc index fbb01c60ca1e5..d3cd46a908980 100644 --- a/src/test/librados/tier_cxx.cc +++ b/src/test/librados/tier_cxx.cc @@ -179,11 +179,17 @@ void is_intended_refcount_state(librados::IoCtx& src_ioctx, } dst_refcount = refs.count(); } - r = cls_cas_references_chunk(src_ioctx, src_oid, dst_oid); - if (r == -ENOENT || r == -ENOLINK) { - src_refcount = 0; - } else { - src_refcount = r; + for (int tries = 0; tries < 10; ++tries) { + r = cls_cas_references_chunk(src_ioctx, src_oid, dst_oid); + if (r == -ENOENT || r == -ENOLINK) { + src_refcount = 0; + } else if (r == -EBUSY) { + sleep(15); + continue; + } else { + src_refcount = r; + } + break; } ASSERT_TRUE(src_refcount >= 0); ASSERT_TRUE(src_refcount == expected_refcount); -- 2.39.5