From c70edf3e037c144570ef5c88e8a1ca8f0747a622 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 26 Dec 2013 17:31:01 -0800 Subject: [PATCH] osd/ReplicatedPG: add PROMOTE log entry type This is an alternative to MODIFY that indicates the object was just promoted from another tier. Thanksfully, is_modify() is used in very few places! Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 20 +++++++++++--------- src/osd/ReplicatedPG.h | 2 +- src/osd/osd_types.h | 12 ++++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 788108a277c45..1dd4f927f0616 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4539,15 +4539,19 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) // clone, if necessary make_writeable(ctx); - finish_ctx(ctx); + finish_ctx(ctx, + ctx->new_obs.exists ? pg_log_entry_t::MODIFY : + pg_log_entry_t::DELETE); return result; } -void ReplicatedPG::finish_ctx(OpContext *ctx) +void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type) { const hobject_t& soid = ctx->obs->oi.soid; - dout(20) << __func__ << " " << soid << " " << ctx << dendl; + dout(20) << __func__ << " " << soid << " " << ctx + << " op " << pg_log_entry_t::get_op_name(log_op_type) + << dendl; // snapset bufferlist bss; @@ -4635,10 +4639,7 @@ void ReplicatedPG::finish_ctx(OpContext *ctx) } // append to log - int logopcode = pg_log_entry_t::MODIFY; - if (!ctx->new_obs.exists) - logopcode = pg_log_entry_t::DELETE; - ctx->log.push_back(pg_log_entry_t(logopcode, soid, ctx->at_version, + ctx->log.push_back(pg_log_entry_t(log_op_type, soid, ctx->at_version, ctx->obs->oi.version, ctx->user_at_version, ctx->reqid, ctx->mtime)); @@ -5061,7 +5062,8 @@ void ReplicatedPG::finish_promote(int r, OpRequestRef op, tctx->lock_to_release = OpContext::W_LOCK; dout(20) << __func__ << " took lock on obc, " << obc->rwstate << dendl; - finish_ctx(tctx); + finish_ctx(tctx, pg_log_entry_t::PROMOTE); + simple_repop_submit(repop); } @@ -5315,7 +5317,7 @@ int ReplicatedPG::try_flush_mark_clean(FlushOpRef fop) ctx->new_obs.oi.clear_flag(object_info_t::FLAG_DIRTY); --ctx->delta_stats.num_objects_dirty; - finish_ctx(ctx); + finish_ctx(ctx, pg_log_entry_t::MODIFY); if (!fop->dup_ops.empty()) { dout(20) << __func__ << " queueing dups for " << ctx->at_version << dendl; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 284635970dc23..c19e79378c5ae 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -775,7 +775,7 @@ protected: const hobject_t& head, const hobject_t& coid, object_info_t *poi); void execute_ctx(OpContext *ctx); - void finish_ctx(OpContext *ctx); + void finish_ctx(OpContext *ctx, int log_op_type); void reply_ctx(OpContext *ctx, int err); void reply_ctx(OpContext *ctx, int err, eversion_t v, version_t uv); void make_writeable(OpContext *ctx); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 11005b5657523..2608b529d0eb2 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1578,18 +1578,21 @@ inline ostream& operator<<(ostream& out, const pg_query_t& q) { */ struct pg_log_entry_t { enum { - MODIFY = 1, - CLONE = 2, - DELETE = 3, + MODIFY = 1, // some unspecified modification (but not *all* modifications) + CLONE = 2, // cloned object from head + DELETE = 3, // deleted object BACKLOG = 4, // event invented by generate_backlog [deprecated] LOST_REVERT = 5, // lost new version, revert to an older version. LOST_DELETE = 6, // lost new version, revert to no object (deleted). LOST_MARK = 7, // lost new version, now EIO + PROMOTE = 8, // promoted object from another tier }; static const char *get_op_name(int op) { switch (op) { case MODIFY: return "modify "; + case PROMOTE: + return "promote "; case CLONE: return "clone "; case DELETE: @@ -1636,13 +1639,14 @@ struct pg_log_entry_t { bool is_clone() const { return op == CLONE; } bool is_modify() const { return op == MODIFY; } + bool is_promote() const { return op == PROMOTE; } bool is_backlog() const { return op == BACKLOG; } bool is_lost_revert() const { return op == LOST_REVERT; } bool is_lost_delete() const { return op == LOST_DELETE; } bool is_lost_mark() const { return op == LOST_MARK; } bool is_update() const { - return is_clone() || is_modify() || is_backlog() || is_lost_revert() || is_lost_mark(); + return is_clone() || is_modify() || is_promote() || is_backlog() || is_lost_revert() || is_lost_mark(); } bool is_delete() const { return op == DELETE || op == LOST_DELETE; -- 2.39.5