From: xie xingguo Date: Sat, 15 Jun 2019 06:24:29 +0000 (+0800) Subject: osdc/Objecter: _calc_target - inline spgid X-Git-Tag: v15.1.0~2420^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28570%2Fhead;p=ceph.git 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 --- diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index f15f491db021..26fcfd0174ea 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 a0ba31e60a28..6033f0366786 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__ << " "