From 522f2ab0d6e6ae9caa01119654eae43e0395b2d0 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 15 Jun 2019 14:24:29 +0800 Subject: [PATCH] osdc/Objecter: _calc_target - inline spgid A follow-up of https://github.com/ceph/ceph/pull/28487. For erasure pools this can save us an obviously redundant call of do_crush and other things. Signed-off-by: xie xingguo --- src/osd/osd_types.h | 3 +++ src/osdc/Objecter.cc | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index f15f491db02..26fcfd0174e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -539,6 +539,9 @@ struct spg_t { uint64_t pool() const { return pgid.pool(); } + void reset_shard(shard_id_t s) { + shard = s; + } static const uint8_t calc_name_buf_size = pg_t::calc_name_buf_size + 4; // 36 + len('s') + len("255"); char *calc_name(char *buf, const char *suffix_backwords) const; diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index a0ba31e60a2..6033f036678 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2943,9 +2943,16 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change) t->pg_num = pg_num; t->pg_num_mask = pg_num_mask; t->pg_num_pending = pg_num_pending; - osdmap->get_primary_shard( - pg_t(ceph_stable_mod(pgid.ps(), t->pg_num, t->pg_num_mask), pgid.pool()), - &t->actual_pgid); + spg_t spgid(actual_pgid); + if (pi->is_erasure()) { + for (uint8_t i = 0; i < acting.size(); ++i) { + if (acting[i] == acting_primary) { + spgid.reset_shard(shard_id_t(i)); + break; + } + } + } + t->actual_pgid = spgid; t->sort_bitwise = sort_bitwise; t->recovery_deletes = recovery_deletes; ldout(cct, 10) << __func__ << " "