From acc2a1e12f04efd6b8c25b92a4a438a73851afe1 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Tue, 6 Apr 2021 10:29:56 +0900 Subject: [PATCH] osd: recover unreadable snapshot before reading ref. count info Manifest objects needs adjacent clones when incrementing/decrementing refcount. This commit makes the current code to call get_manifest_ref_count before reading ref. count info. Signed-off-by: Myoungwon Oh --- src/osd/PrimaryLogPG.cc | 6 +++++- src/osd/PrimaryLogPG.h | 2 +- src/osd/objclass.cc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 8d01780a8053f..161134237b508 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3381,7 +3381,7 @@ void PrimaryLogPG::cancel_manifest_ops(bool requeue, vector *tids) } } -int PrimaryLogPG::get_manifest_ref_count(ObjectContextRef obc, std::string& fp_oid) +int PrimaryLogPG::get_manifest_ref_count(ObjectContextRef obc, std::string& fp_oid, OpRequestRef op) { int cnt = 0; // head @@ -3408,6 +3408,9 @@ int PrimaryLogPG::get_manifest_ref_count(ObjectContextRef obc, std::string& fp_o if (!clone_obc) { break; } + if (recover_adjacent_clones(obc, op)) { + return -EAGAIN; + } get_adjacent_clones(clone_obc, obc_l, obc_g); clone_obc->obs.oi.manifest.calc_refs_to_inc_on_set( obc_g ? &(obc_g->obs.oi.manifest) : nullptr , @@ -3428,6 +3431,7 @@ bool PrimaryLogPG::recover_adjacent_clones(ObjectContextRef obc, OpRequestRef op if (!obc->obs.oi.manifest.is_chunked() || !obc->ssc || !obc->ssc->snapset.clones.size()) { return false; } + ceph_assert(op); const SnapSet& snapset = obc->ssc->snapset; auto s = std::find(snapset.clones.begin(), snapset.clones.end(), obc->obs.oi.soid.snap); diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index e9f9cb9c828cb..e84078be38253 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1811,7 +1811,7 @@ public: void maybe_kick_recovery(const hobject_t &soid); void wait_for_unreadable_object(const hobject_t& oid, OpRequestRef op); - int get_manifest_ref_count(ObjectContextRef obc, std::string& fp_oid); + int get_manifest_ref_count(ObjectContextRef obc, std::string& fp_oid, OpRequestRef op); bool check_laggy(OpRequestRef& op); bool check_laggy_requeue(OpRequestRef& op); diff --git a/src/osd/objclass.cc b/src/osd/objclass.cc index 6130ecce2256d..274f5e063e62b 100644 --- a/src/osd/objclass.cc +++ b/src/osd/objclass.cc @@ -685,7 +685,7 @@ int cls_cxx_chunk_write_and_set(cls_method_context_t hctx, int ofs, int len, int cls_get_manifest_ref_count(cls_method_context_t hctx, string fp_oid) { PrimaryLogPG::OpContext *ctx = *(PrimaryLogPG::OpContext **)hctx; - return ctx->pg->get_manifest_ref_count(ctx->obc, fp_oid); + return ctx->pg->get_manifest_ref_count(ctx->obc, fp_oid, ctx->op); } uint64_t cls_get_osd_min_alloc_size(cls_method_context_t hctx) { -- 2.39.5