From: myoungwon oh Date: Tue, 5 Jan 2021 12:40:36 +0000 (+0900) Subject: osd: add has_manifest_chunk() to check chunks in snapshot X-Git-Tag: v17.1.0~3122^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bdcedd4e9f2efed59b1e5c2d40171e6da595a259;p=ceph.git osd: add has_manifest_chunk() to check chunks in snapshot cls_has_chunk does not cover snapshotted manifest object. This leads to unexpected behavior during chunk scrub. Signed-off-by: Myoungwon Oh --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 663b8fb011d5..4b065f950816 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3328,6 +3328,34 @@ void PrimaryLogPG::cancel_manifest_ops(bool requeue, vector *tids) } } +bool PrimaryLogPG::has_manifest_chunk(ObjectContextRef obc, std::string& fp_oid) +{ + // head + for (auto &p : obc->obs.oi.manifest.chunk_map) { + if (p.second.oid.oid.name == fp_oid) { + return true; + } + } + // snap + SnapSet& ss = obc->ssc->snapset; + for (vector::const_iterator p = ss.clones.begin(); + p != ss.clones.end(); + ++p) { + hobject_t clone_oid = obc->obs.oi.soid; + clone_oid.snap = *p; + ObjectContextRef clone_obc = get_object_context(clone_oid, false); + if (clone_obc && clone_obc->obs.oi.has_manifest()) { + for (auto &p : clone_obc->obs.oi.manifest.chunk_map) { + if (p.second.oid.oid.name == fp_oid) { + return true; + } + } + } + } + + return false; +} + ObjectContextRef PrimaryLogPG::get_prev_clone_obc(ObjectContextRef obc) { auto s = std::find(obc->ssc->snapset.clones.begin(), obc->ssc->snapset.clones.end(), diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 432a7f9c3366..189c61a4da96 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1848,6 +1848,8 @@ public: void maybe_kick_recovery(const hobject_t &soid); void wait_for_unreadable_object(const hobject_t& oid, OpRequestRef op); + bool has_manifest_chunk(ObjectContextRef obc, std::string& fp_oid); + bool check_laggy(OpRequestRef& op); bool check_laggy_requeue(OpRequestRef& op); void recheck_readable() override; diff --git a/src/osd/objclass.cc b/src/osd/objclass.cc index 73c5406856a5..7507a55d1c90 100644 --- a/src/osd/objclass.cc +++ b/src/osd/objclass.cc @@ -685,17 +685,7 @@ int cls_cxx_chunk_write_and_set(cls_method_context_t hctx, int ofs, int len, bool cls_has_chunk(cls_method_context_t hctx, string fp_oid) { PrimaryLogPG::OpContext *ctx = *(PrimaryLogPG::OpContext **)hctx; - if (!ctx->obc->obs.oi.has_manifest()) { - return false; - } - - for (auto &p : ctx->obc->obs.oi.manifest.chunk_map) { - if (p.second.oid.oid.name == fp_oid) { - return true; - } - } - - return false; + return ctx->pg->has_manifest_chunk(ctx->obc, fp_oid); } uint64_t cls_get_osd_min_alloc_size(cls_method_context_t hctx) {