From 82aedd8fddec687ff85e672dd35675332f390fd4 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Wed, 26 Aug 2020 15:38:04 +0900 Subject: [PATCH] osd: chunk_info must hold a reference Every mapping in chunk_map must have a corresponding refcount Signed-off-by: Myoungwon Oh --- src/osd/PrimaryLogPG.cc | 36 ++++++++++++------------------------ src/osd/PrimaryLogPG.h | 1 - 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 2a563170039..29ce96904a3 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -2344,16 +2344,6 @@ void PrimaryLogPG::do_op(OpRequestRef& op) maybe_force_recovery(); } -bool PrimaryLogPG::is_dedup_chunk(const chunk_info_t& chunk) -{ - if (pg_pool_t::fingerprint_t fp_algo = pool.info.get_fingerprint_type(); - chunk.has_reference() && - fp_algo != pg_pool_t::TYPE_FINGERPRINT_NONE) { - return true; - } - return false; -} - PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_manifest_detail( OpRequestRef op, bool write_ordered, @@ -3348,14 +3338,12 @@ void PrimaryLogPG::dec_refcount_by_dirty(OpContext* ctx) ObjectContextRef cobc = nullptr; ObjectContextRef obc = ctx->obc; for (auto &p : ctx->obs->oi.manifest.chunk_map) { - if (is_dedup_chunk(p.second)) { - if (!ctx->clean_regions.is_clean_region(p.first, p.second.length)) { - ctx->new_obs.oi.manifest.chunk_map.erase(p.first); - if (ctx->new_obs.oi.manifest.chunk_map.empty()) { - ctx->new_obs.oi.manifest.type = object_manifest_t::TYPE_NONE; - ctx->new_obs.oi.clear_flag(object_info_t::FLAG_MANIFEST); - ctx->delta_stats.num_objects_manifest--; - } + if (!ctx->clean_regions.is_clean_region(p.first, p.second.length)) { + ctx->new_obs.oi.manifest.chunk_map.erase(p.first); + if (ctx->new_obs.oi.manifest.chunk_map.empty()) { + ctx->new_obs.oi.manifest.type = object_manifest_t::TYPE_NONE; + ctx->new_obs.oi.clear_flag(object_info_t::FLAG_MANIFEST); + ctx->delta_stats.num_objects_manifest--; } } } @@ -6882,6 +6870,10 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) result = -ERANGE; goto fail; } + if (!(osd_op.op.flags & CEPH_OSD_OP_FLAG_WITH_REFERENCE)) { + result = -EOPNOTSUPP; + break; + } for (auto &p : oi.manifest.chunk_map) { interval_set chunk; @@ -6900,7 +6892,6 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) hobject_t target(tgt_name, tgt_oloc.key, snapid_t(), raw_pg.ps(), raw_pg.pool(), tgt_oloc.nspace); - bool need_reference = (osd_op.op.flags & CEPH_OSD_OP_FLAG_WITH_REFERENCE); bool has_reference = (oi.manifest.chunk_map.find(src_offset) != oi.manifest.chunk_map.end()) && (oi.manifest.chunk_map[src_offset].test_flag(chunk_info_t::FLAG_HAS_REFERENCE)); if (has_reference) { @@ -6911,7 +6902,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) chunk_info.oid = target; chunk_info.offset = tgt_offset; chunk_info.length = src_length; - if (op_finisher == nullptr && need_reference) { + if (op_finisher == nullptr) { // start ctx->op_finishers[ctx->current_osd_subop_num].reset( new SetManifestFinisher(osd_op)); @@ -6935,12 +6926,9 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) ctx->delta_stats.num_objects_manifest++; oi.set_flag(object_info_t::FLAG_MANIFEST); oi.manifest.type = object_manifest_t::TYPE_CHUNKED; - if (!has_reference && need_reference) { + if (!has_reference) { oi.manifest.chunk_map[src_offset].set_flag(chunk_info_t::FLAG_HAS_REFERENCE); } - if (need_reference && pool.info.get_fingerprint_type() != pg_pool_t::TYPE_FINGERPRINT_NONE) { - oi.manifest.chunk_map[src_offset].set_flag(chunk_info_t::FLAG_HAS_FINGERPRINT); - } ctx->modify = true; ctx->cache_operation = true; diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index f68d2ee2ef0..f6f30bf0e05 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1496,7 +1496,6 @@ protected: void dec_all_refcount_manifest(const object_info_t& oi, OpContext* ctx); void dec_refcount(const hobject_t& soid, const object_ref_delta_t& refs); void dec_refcount_by_dirty(OpContext* ctx); - bool is_dedup_chunk(const chunk_info_t& chunk); ObjectContextRef get_prev_clone_obc(ObjectContextRef obc); void get_adjacent_clones(const object_info_t& oi, OpContext* ctx, ObjectContextRef& _l, ObjectContextRef& _g); -- 2.39.5