From: Samuel Just Date: Wed, 17 Jul 2013 19:51:19 +0000 (-0700) Subject: ReplicatedPG: replace clean_up_local with a debug check X-Git-Tag: v0.67-rc1~40 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=278c7b59228f614addf830cb0afff4988c9bc8cb;p=ceph.git ReplicatedPG: replace clean_up_local with a debug check Stray objects should have been cleaned up in the merge_log transactions. Only on the primary have those operations necessarily been flushed at activate(). Fixes: 5084 Signed-off-by: Samuel Just Reviewed-by: Sage Weil --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 94e737387c41..1d1377c72d5c 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -461,6 +461,7 @@ OPTION(osd_debug_drop_pg_create_duration, OPT_INT, 1) OPTION(osd_debug_drop_op_probability, OPT_DOUBLE, 0) // probability of stalling/dropping a client op OPTION(osd_debug_op_order, OPT_BOOL, false) OPTION(osd_debug_verify_snaps_on_info, OPT_BOOL, false) +OPTION(osd_debug_verify_stray_on_activate, OPT_BOOL, false) OPTION(osd_debug_skip_full_check_in_backfill_reservation, OPT_BOOL, false) OPTION(osd_op_history_size, OPT_U32, 20) // Max number of completed ops to track OPTION(osd_op_history_duration, OPT_U32, 600) // Oldest completed op to track diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 46c6f3959979..0663b86665dc 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1132,8 +1132,9 @@ void PG::activate(ObjectStore::Transaction& t, dirty_info = true; dirty_big_info = true; // maybe - // clean up stray objects - clean_up_local(t); + // verify that there are no stray objects + if (is_primary()) + check_local(); // find out when we commit tfin.push_back(new C_PG_ActivateCommitted(this, query_epoch)); diff --git a/src/osd/PG.h b/src/osd/PG.h index 2239e6b12758..e1f64dbc9fb6 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -613,7 +613,7 @@ public: return pg_log.get_missing().num_missing() - missing_loc.size(); } - virtual void clean_up_local(ObjectStore::Transaction& t) = 0; + virtual void check_local() = 0; virtual int start_recovery_ops(int max, RecoveryCtx *prctx) = 0; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 918498edc554..14708e38cd98 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -7502,16 +7502,19 @@ void ReplicatedPG::scan_range(hobject_t begin, int min, int max, BackfillInterva } -/** clean_up_local - * remove any objects that we're storing but shouldn't. - * as determined by log. +/** check_local + * + * verifies that stray objects have been deleted */ -void ReplicatedPG::clean_up_local(ObjectStore::Transaction& t) +void ReplicatedPG::check_local() { - dout(10) << "clean_up_local" << dendl; + dout(10) << __func__ << dendl; assert(info.last_update >= pg_log.get_tail()); // otherwise we need some help! + if (!g_conf->osd_debug_verify_stray_on_activate) + return; + // just scan the log. set did; for (list::const_reverse_iterator p = pg_log.get_log().log.rbegin(); @@ -7522,11 +7525,17 @@ void ReplicatedPG::clean_up_local(ObjectStore::Transaction& t) did.insert(p->soid); if (p->is_delete()) { - dout(10) << " deleting " << p->soid - << " when " << p->version << dendl; - remove_snap_mapped_object(t, p->soid); + dout(10) << " checking " << p->soid + << " at " << p->version << dendl; + struct stat st; + int r = osd->store->stat(coll, p->soid, &st); + if (r != -ENOENT) { + dout(10) << "Object " << p->soid << " exists, but should have been " + << "deleted" << dendl; + assert(0 == "erroneously present object"); + } } else { - // keep old(+missing) objects, just for kicks. + // ignore old(+missing) objects } } } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 4cedf913217f..8f0cf6ec31c2 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -750,7 +750,7 @@ protected: int prepare_transaction(OpContext *ctx); // pg on-disk content - void clean_up_local(ObjectStore::Transaction& t); + void check_local(); void _clear_recovery_state();