From: Kefu Chai Date: Sun, 26 Mar 2017 04:05:12 +0000 (+0800) Subject: mon/OSDMonitor: pass by reference not pointer of const param X-Git-Tag: v12.0.2~256^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebde28b683a5588f6d74dcc6b7193512d6a675ab;p=ceph.git mon/OSDMonitor: pass by reference not pointer of const param Signed-off-by: Kefu Chai --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 8a76f66ed02e..e01a5179e8b8 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -9015,27 +9015,27 @@ bool OSDMonitor::prepare_pool_op_create(MonOpRequestRef op) return true; } -int OSDMonitor::_check_remove_pool(int64_t pool, const pg_pool_t *p, +int OSDMonitor::_check_remove_pool(int64_t pool_id, const pg_pool_t& pool, ostream *ss) { - const string& poolstr = osdmap.get_pool_name(pool); + const string& poolstr = osdmap.get_pool_name(pool_id); // If the Pool is in use by CephFS, refuse to delete it FSMap const &pending_fsmap = mon->mdsmon()->get_pending(); - if (pending_fsmap.pool_in_use(pool)) { + if (pending_fsmap.pool_in_use(pool_id)) { *ss << "pool '" << poolstr << "' is in use by CephFS"; return -EBUSY; } - if (p->tier_of >= 0) { + if (pool.tier_of >= 0) { *ss << "pool '" << poolstr << "' is a tier of '" - << osdmap.get_pool_name(p->tier_of) << "'"; + << osdmap.get_pool_name(pool.tier_of) << "'"; return -EBUSY; } - if (!p->tiers.empty()) { + if (!pool.tiers.empty()) { *ss << "pool '" << poolstr << "' has tiers"; - for(std::set::iterator i = p->tiers.begin(); i != p->tiers.end(); ++i) { - *ss << " " << osdmap.get_pool_name(*i); + for(auto tier : pool.tiers) { + *ss << " " << osdmap.get_pool_name(tier); } return -EBUSY; } @@ -9045,7 +9045,7 @@ int OSDMonitor::_check_remove_pool(int64_t pool, const pg_pool_t *p, return -EPERM; } - if (p->has_flag(pg_pool_t::FLAG_NODELETE)) { + if (pool.has_flag(pg_pool_t::FLAG_NODELETE)) { *ss << "pool deletion is disabled; you must unset nodelete flag for the pool first"; return -EPERM; } @@ -9157,14 +9157,14 @@ int OSDMonitor::_prepare_remove_pool(int64_t pool, ostream *ss) { dout(10) << "_prepare_remove_pool " << pool << dendl; const pg_pool_t *p = osdmap.get_pg_pool(pool); - int r = _check_remove_pool(pool, p, ss); + int r = _check_remove_pool(pool, *p, ss); if (r < 0) return r; if (pending_inc.new_pools.count(pool)) { // if there is a problem with the pending info, wait and retry // this op. - pg_pool_t *p = &pending_inc.new_pools[pool]; + const auto& p = pending_inc.new_pools[pool]; int r = _check_remove_pool(pool, p, ss); if (r < 0) return -EAGAIN; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 54886e242028..d7c4b64ee302 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -283,7 +283,7 @@ private: bool preprocess_pg_created(MonOpRequestRef op); bool prepare_pg_created(MonOpRequestRef op); - int _check_remove_pool(int64_t pool, const pg_pool_t *pi, ostream *ss); + int _check_remove_pool(int64_t pool_id, const pg_pool_t &pool, ostream *ss); bool _check_become_tier( int64_t tier_pool_id, const pg_pool_t *tier_pool, int64_t base_pool_id, const pg_pool_t *base_pool,