Skip to content

Commit

Permalink
Merge pull request ceph#18059 from Liuchang0812/remove-duplicated-func
Browse files Browse the repository at this point in the history
osd: remove duplicated function ec_pool in pg_pool_t

Reviewed-by: xie xingguo <[email protected]>
  • Loading branch information
tchaikov authored Oct 2, 2017
2 parents 8233596 + 6597e04 commit 7a663ae
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10161,7 +10161,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
err = -ENOTEMPTY;
goto reply;
}
if (tp->ec_pool()) {
if (tp->is_erasure()) {
ss << "tier pool '" << tierpoolstr
<< "' is an ec pool, which cannot be a tier";
err = -ENOTSUP;
Expand Down
4 changes: 2 additions & 2 deletions src/osd/OSDMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1129,14 +1129,14 @@ class OSDMap {
bool pg_is_ec(pg_t pg) const {
auto i = pools.find(pg.pool());
assert(i != pools.end());
return i->second.ec_pool();
return i->second.is_erasure();
}
bool get_primary_shard(const pg_t& pgid, spg_t *out) const {
auto i = get_pools().find(pgid.pool());
if (i == get_pools().end()) {
return false;
}
if (!i->second.ec_pool()) {
if (!i->second.is_erasure()) {
*out = spg_t(pgid);
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ PastIntervals::PriorSet PG::build_prior()

const OSDMap &osdmap = *get_osdmap();
PastIntervals::PriorSet prior = past_intervals.get_prior_set(
pool.info.ec_pool(),
pool.info.is_erasure(),
info.history.last_epoch_started,
get_pgbackend()->get_is_recoverable_predicate(),
[&](epoch_t start, int osd, epoch_t *lost_at) {
Expand Down Expand Up @@ -1388,7 +1388,7 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id,
vector<int> want;
pg_shard_t want_primary;
stringstream ss;
if (!pool.info.ec_pool())
if (!pool.info.is_erasure())
calc_replicated_acting(
auth_log_shard,
get_osdmap()->get_pg_size(info.pgid.pgid),
Expand Down Expand Up @@ -1425,15 +1425,15 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id,
have.insert(
pg_shard_t(
want[i],
pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
pool.info.is_erasure() ? shard_id_t(i) : shard_id_t::NO_SHARD));
}
}

// We go incomplete if below min_size for ec_pools since backfill
// does not currently maintain rollbackability
// Otherwise, we will go "peered", but not "active"
if (num_want_acting < pool.info.min_size &&
(pool.info.ec_pool() ||
(pool.info.is_erasure() ||
!cct->_conf->osd_allow_recovery_below_min_size)) {
want_acting.clear();
dout(10) << "choose_acting failed, below min size" << dendl;
Expand Down Expand Up @@ -1503,7 +1503,7 @@ void PG::build_might_have_unfound()

might_have_unfound = past_intervals.get_might_have_unfound(
pg_whoami,
pool.info.ec_pool());
pool.info.is_erasure());

// include any (stray) peers
for (map<pg_shard_t, pg_info_t>::iterator p = peer_info.begin();
Expand Down
12 changes: 6 additions & 6 deletions src/osd/PG.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class PG : public DoutPrefixProvider {

public:
bool is_ec_pg() const {
return pool.info.ec_pool();
return pool.info.is_erasure();
}
// pg state
pg_info_t info; ///< current pg info
Expand Down Expand Up @@ -957,10 +957,10 @@ class PG : public DoutPrefixProvider {
return actingbackfill.count(osd);
}
bool is_acting(pg_shard_t osd) const {
return has_shard(pool.info.ec_pool(), acting, osd);
return has_shard(pool.info.is_erasure(), acting, osd);
}
bool is_up(pg_shard_t osd) const {
return has_shard(pool.info.ec_pool(), up, osd);
return has_shard(pool.info.is_erasure(), up, osd);
}
static bool has_shard(bool ec, const vector<int>& v, pg_shard_t osd) {
if (ec) {
Expand Down Expand Up @@ -2265,7 +2265,7 @@ class PG : public DoutPrefixProvider {
actingset.insert(
pg_shard_t(
acting[i],
pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
pool.info.is_erasure() ? shard_id_t(i) : shard_id_t::NO_SHARD));
}
upset.clear();
up = newup;
Expand All @@ -2274,9 +2274,9 @@ class PG : public DoutPrefixProvider {
upset.insert(
pg_shard_t(
up[i],
pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
pool.info.is_erasure() ? shard_id_t(i) : shard_id_t::NO_SHARD));
}
if (!pool.info.ec_pool()) {
if (!pool.info.is_erasure()) {
up_primary = pg_shard_t(new_up_primary, shard_id_t::NO_SHARD);
primary = pg_shard_t(new_acting_primary, shard_id_t::NO_SHARD);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/osd/PrimaryLogPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ int PrimaryLogPG::do_command(
cmd_getval(cct, cmdmap, "mulcmd", mulcmd);
int mode = -1;
if (mulcmd == "revert") {
if (pool.info.ec_pool()) {
if (pool.info.is_erasure()) {
ss << "mode must be 'delete' for ec pool";
return -EINVAL;
}
Expand Down Expand Up @@ -4774,7 +4774,7 @@ int PrimaryLogPG::do_sparse_read(OpContext *ctx, OSDOp& osd_op) {
}

++ctx->num_read;
if (pool.info.ec_pool()) {
if (pool.info.is_erasure()) {
// translate sparse read to a normal one if not supported
uint64_t offset = op.extent.offset;
uint64_t length = op.extent.length;
Expand Down Expand Up @@ -10380,7 +10380,7 @@ void PrimaryLogPG::do_update_log_missing(OpRequestRef &op)
*
* This behavior is no longer necessary, but we preserve it so old
* primaries can keep their repops in order */
if (pool.info.ec_pool()) {
if (pool.info.is_erasure()) {
t.register_on_complete(complete);
} else {
t.register_on_commit(complete);
Expand Down
4 changes: 2 additions & 2 deletions src/osd/osd_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ void pg_pool_t::convert_to_pg_shards(const vector<int> &from, set<pg_shard_t>* t
to->insert(
pg_shard_t(
from[i],
ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
is_erasure() ? shard_id_t(i) : shard_id_t::NO_SHARD));
}
}
}
Expand Down Expand Up @@ -3446,7 +3446,7 @@ bool PastIntervals::check_new_interval(
if (out)
*out << __func__ << " " << i << " : acting set is too small" << std::endl;
}
past_intervals->past_intervals->add_interval(old_pg_pool.ec_pool(), i);
past_intervals->past_intervals->add_interval(old_pg_pool.is_erasure(), i);
return true;
} else {
return false;
Expand Down
5 changes: 1 addition & 4 deletions src/osd/osd_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1449,11 +1449,8 @@ struct pg_pool_t {
void set_flag(uint64_t f) { flags |= f; }
void unset_flag(uint64_t f) { flags &= ~f; }

bool ec_pool() const {
return type == TYPE_ERASURE;
}
bool require_rollback() const {
return ec_pool();
return is_erasure();
}

/// true if incomplete clones may be present
Expand Down

0 comments on commit 7a663ae

Please sign in to comment.