Merge pull request #24743 from rzarzynski/wip-osd-avoid-osdmap-refcounting

core: avoid unnecessary refcounting of OSDMap on OSD's hot paths

Reviewed-by: Kefu Chai <kchai@redhat.com>
Reviewed-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
Xie Xingguo 2018-10-27 09:51:13 +08:00 committed by GitHub
commit 19b2995378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 12 deletions

View File

@ -2978,7 +2978,7 @@ protected:
return e <= cur_epoch;
}
bool have_same_or_newer_map(epoch_t e) {
return e <= get_osdmap()->get_epoch();
return e <= get_osdmap_epoch();
}
bool op_has_sufficient_caps(OpRequestRef& op);

View File

@ -206,6 +206,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
virtual const PGLog &get_log() const = 0;
virtual bool pgb_is_primary() const = 0;
virtual OSDMapRef pgb_get_osdmap() const = 0;
virtual epoch_t pgb_get_osdmap_epoch() const = 0;
virtual const pg_info_t &get_info() const = 0;
virtual const pg_pool_t &get_pool() const = 0;
@ -309,6 +310,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
parent(l) {}
bool is_primary() const { return get_parent()->pgb_is_primary(); }
OSDMapRef get_osdmap() const { return get_parent()->pgb_get_osdmap(); }
epoch_t get_osdmap_epoch() const { return get_parent()->pgb_get_osdmap_epoch(); }
const pg_info_t &get_info() { return get_parent()->get_info(); }
std::ostream& gen_prefix(std::ostream& out) const {

View File

@ -134,7 +134,7 @@ public:
GenContext<ThreadPool::TPHandle&> *PrimaryLogPG::bless_gencontext(
GenContext<ThreadPool::TPHandle&> *c) {
return new BlessedGenContext<ThreadPool::TPHandle&>(
this, c, get_osdmap()->get_epoch());
this, c, get_osdmap_epoch());
}
template <typename T>
@ -161,7 +161,7 @@ public:
GenContext<ThreadPool::TPHandle&> *PrimaryLogPG::bless_unlocked_gencontext(
GenContext<ThreadPool::TPHandle&> *c) {
return new UnlockedBlessedGenContext<ThreadPool::TPHandle&>(
this, c, get_osdmap()->get_epoch());
this, c, get_osdmap_epoch());
}
class PrimaryLogPG::BlessedContext : public Context {
@ -187,7 +187,7 @@ public:
};
Context *PrimaryLogPG::bless_context(Context *c) {
return new BlessedContext(this, c, get_osdmap()->get_epoch());
return new BlessedContext(this, c, get_osdmap_epoch());
}
class PrimaryLogPG::C_PG_ObjectContext : public Context {
@ -3951,7 +3951,7 @@ void PrimaryLogPG::execute_ctx(OpContext *ctx)
bool successful_write = !ctx->op_t->empty() && op->may_write() && result >= 0;
// prepare the reply
ctx->reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0,
ctx->reply = new MOSDOpReply(m, 0, get_osdmap_epoch(), 0,
successful_write);
// Write operations aren't allowed to return a data payload because
@ -4039,7 +4039,7 @@ void PrimaryLogPG::execute_ctx(OpContext *ctx)
if (reply)
ctx->reply = nullptr;
else {
reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0, true);
reply = new MOSDOpReply(m, 0, get_osdmap_epoch(), 0, true);
reply->set_reply_versions(ctx->at_version,
ctx->user_at_version);
}

View File

@ -369,9 +369,12 @@ public:
bool pgb_is_primary() const override {
return is_primary();
}
OSDMapRef pgb_get_osdmap() const override {
OSDMapRef pgb_get_osdmap() const override final {
return get_osdmap();
}
epoch_t pgb_get_osdmap_epoch() const override final {
return get_osdmap_epoch();
}
const pg_info_t &get_info() const override {
return info;
}

View File

@ -902,7 +902,7 @@ Message * ReplicatedBackend::generate_subop(
reqid, parent->whoami_shard(),
spg_t(get_info().pgid.pgid, peer.shard),
soid, acks_wanted,
get_osdmap()->get_epoch(),
get_osdmap_epoch(),
parent->get_last_peering_reset_epoch(),
tid, at_version);
@ -981,7 +981,7 @@ void ReplicatedBackend::issue_op(
if (op->op && op->op->pg_trace)
wr->trace.init("replicated op", nullptr, &op->op->pg_trace);
get_parent()->send_message_osd_cluster(
shard.osd, wr, get_osdmap()->get_epoch());
shard.osd, wr, get_osdmap_epoch());
}
}
}
@ -1016,7 +1016,7 @@ void ReplicatedBackend::do_repop(OpRequestRef op)
rm->op = op;
rm->ackerosd = ackerosd;
rm->last_complete = get_info().last_complete;
rm->epoch_started = get_osdmap()->get_epoch();
rm->epoch_started = get_osdmap_epoch();
ceph_assert(m->logbl.length());
// shipped transaction and log entries
@ -1106,12 +1106,12 @@ void ReplicatedBackend::repop_commit(RepModifyRef rm)
MOSDRepOpReply *reply = new MOSDRepOpReply(
m,
get_parent()->whoami_shard(),
0, get_osdmap()->get_epoch(), m->get_min_epoch(), CEPH_OSD_FLAG_ONDISK);
0, get_osdmap_epoch(), m->get_min_epoch(), CEPH_OSD_FLAG_ONDISK);
reply->set_last_complete_ondisk(rm->last_complete);
reply->set_priority(CEPH_MSG_PRIO_HIGH); // this better match ack priority!
reply->trace = rm->op->pg_trace;
get_parent()->send_message_osd_cluster(
rm->ackerosd, reply, get_osdmap()->get_epoch());
rm->ackerosd, reply, get_osdmap_epoch());
log_subop_stats(get_parent()->get_logger(), rm->op, l_osd_sop_w);
}