From: Guang G Yang Date: Wed, 1 Jul 2015 20:26:54 +0000 (+0000) Subject: osd: Move IsRecoverablePredicate/IsReadablePredicate to osd_types.h X-Git-Tag: v9.1.0~497^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=466b083166231ec7e4c069fef8c9e07d38accab9;p=ceph.git osd: Move IsRecoverablePredicate/IsReadablePredicate to osd_types.h Signed-off-by: Guang Yang --- diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index d1062686fc91..9073c1e7e5b3 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -385,7 +385,7 @@ public: * * Determines the whether _have is suffient to recover an object */ - class ECRecPred : public IsRecoverablePredicate { + class ECRecPred : public IsPGRecoverablePredicate { set want; ErasureCodeInterfaceRef ec_impl; public: @@ -405,7 +405,7 @@ public: return ec_impl->minimum_to_decode(want, have, &min) == 0; } }; - IsRecoverablePredicate *get_is_recoverable_predicate() { + IsPGRecoverablePredicate *get_is_recoverable_predicate() { return new ECRecPred(ec_impl); } @@ -414,7 +414,7 @@ public: * * Determines the whether _have is suffient to read an object */ - class ECReadPred : public IsReadablePredicate { + class ECReadPred : public IsPGReadablePredicate { pg_shard_t whoami; ECRecPred rec_pred; public: @@ -425,7 +425,7 @@ public: return _have.count(whoami) && rec_pred(_have); } }; - IsReadablePredicate *get_is_readable_predicate() { + IsPGReadablePredicate *get_is_readable_predicate() { return new ECReadPred(get_parent()->whoami_shard(), ec_impl); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 217de9f50dbe..7bb81bfdca4e 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1355,7 +1355,7 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id) } /* Check whether we have enough acting shards to later perform recovery */ - boost::scoped_ptr recoverable_predicate( + boost::scoped_ptr recoverable_predicate( get_pgbackend()->get_is_recoverable_predicate()); set have; for (int i = 0; i < (int)want.size(); ++i) { @@ -7394,7 +7394,7 @@ void PG::RecoveryState::RecoveryMachine::log_exit(const char *state_name, utime_ #define dout_prefix (*_dout << (debug_pg ? debug_pg->gen_prefix() : string()) << " PriorSet: ") PG::PriorSet::PriorSet(bool ec_pool, - PGBackend::IsRecoverablePredicate *c, + IsPGRecoverablePredicate *c, const OSDMap &osdmap, const map &past_intervals, const vector &up, diff --git a/src/osd/PG.h b/src/osd/PG.h index 6b7376b68550..b1aff2addc7f 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -314,13 +314,13 @@ public: PG *pg; set empty_set; public: - boost::scoped_ptr is_readable; - boost::scoped_ptr is_recoverable; + boost::scoped_ptr is_readable; + boost::scoped_ptr is_recoverable; MissingLoc(PG *pg) : pg(pg) {} void set_backend_predicates( - PGBackend::IsReadablePredicate *_is_readable, - PGBackend::IsRecoverablePredicate *_is_recoverable) { + IsPGReadablePredicate *_is_readable, + IsPGRecoverablePredicate *_is_recoverable) { is_readable.reset(_is_readable); is_recoverable.reset(_is_recoverable); } @@ -495,9 +495,9 @@ public: map blocked_by; /// current lost_at values for any OSDs in cur set for which (re)marking them lost would affect cur set bool pg_down; /// some down osds are included in @a cur; the DOWN pg state bit should be set. - boost::scoped_ptr pcontdec; + boost::scoped_ptr pcontdec; PriorSet(bool ec_pool, - PGBackend::IsRecoverablePredicate *c, + IsPGRecoverablePredicate *c, const OSDMap &osdmap, const map &past_intervals, const vector &up, diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 90162ca513da..518fdf4be850 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -319,25 +319,8 @@ virtual void on_flushed() = 0; - class IsRecoverablePredicate { - public: - /** - * have encodes the shards available - */ - virtual bool operator()(const set &have) const = 0; - virtual ~IsRecoverablePredicate() {} - }; - virtual IsRecoverablePredicate *get_is_recoverable_predicate() = 0; - - class IsReadablePredicate { - public: - /** - * have encodes the shards available - */ - virtual bool operator()(const set &have) const = 0; - virtual ~IsReadablePredicate() {} - }; - virtual IsReadablePredicate *get_is_readable_predicate() = 0; + virtual IsPGRecoverablePredicate *get_is_recoverable_predicate() = 0; + virtual IsPGReadablePredicate *get_is_readable_predicate() = 0; virtual void dump_recovery_info(Formatter *f) const = 0; diff --git a/src/osd/ReplicatedBackend.h b/src/osd/ReplicatedBackend.h index 51edf6f10855..55bef8de5dab 100644 --- a/src/osd/ReplicatedBackend.h +++ b/src/osd/ReplicatedBackend.h @@ -72,17 +72,17 @@ public: void clear_recovery_state(); void on_flushed(); - class RPCRecPred : public IsRecoverablePredicate { + class RPCRecPred : public IsPGRecoverablePredicate { public: bool operator()(const set &have) const { return !have.empty(); } }; - IsRecoverablePredicate *get_is_recoverable_predicate() { + IsPGRecoverablePredicate *get_is_recoverable_predicate() { return new RPCRecPred; } - class RPCReadPred : public IsReadablePredicate { + class RPCReadPred : public IsPGReadablePredicate { pg_shard_t whoami; public: RPCReadPred(pg_shard_t whoami) : whoami(whoami) {} @@ -90,7 +90,7 @@ public: return have.count(whoami); } }; - IsReadablePredicate *get_is_readable_predicate() { + IsPGReadablePredicate *get_is_readable_predicate() { return new RPCReadPred(get_parent()->whoami_shard()); } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 6b44aebb7d51..05ae133c13e9 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -95,6 +95,24 @@ WRITE_EQ_OPERATORS_2(pg_shard_t, osd, shard) WRITE_CMP_OPERATORS_2(pg_shard_t, osd, shard) ostream &operator<<(ostream &lhs, const pg_shard_t &rhs); +class IsPGRecoverablePredicate { +public: + /** + * have encodes the shards available + */ + virtual bool operator()(const set &have) const = 0; + virtual ~IsPGRecoverablePredicate() {} +}; + +class IsPGReadablePredicate { +public: + /** + * have encodes the shards available + */ + virtual bool operator()(const set &have) const = 0; + virtual ~IsPGReadablePredicate() {} +}; + inline ostream& operator<<(ostream& out, const osd_reqid_t& r) { return out << r.name << "." << r.inc << ":" << r.tid; }