From: Samuel Just Date: Tue, 28 Jan 2014 00:52:05 +0000 (-0800) Subject: PGBackend: add some additional helpers. X-Git-Tag: v0.78~163^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=facec7654c66ed57106505455f51a38e9678fa8d;p=ceph.git PGBackend: add some additional helpers. ECBackend's primary specific logic mostly won't treat the primary shard specially, so it'll be handy to have primary agnostic helpers for get_shard_info and get_shard_missing. Signed-off-by: Samuel Just --- diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index b39a54efe23f..5332530fe9bc 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -118,12 +118,41 @@ virtual const map > &get_missing_loc_shards() const = 0; + virtual const pg_missing_t &get_local_missing() const = 0; virtual const map &get_shard_missing() const = 0; + virtual boost::optional maybe_get_shard_missing( + pg_shard_t peer) const { + if (peer == primary_shard()) { + return get_local_missing(); + } else { + map::const_iterator i = + get_shard_missing().find(peer); + if (i == get_shard_missing().end()) { + return boost::optional(); + } else { + return i->second; + } + } + } + virtual const pg_missing_t &get_shard_missing(pg_shard_t peer) const { + boost::optional m = maybe_get_shard_missing(peer); + assert(m); + return *m; + } virtual const map &get_shard_info() const = 0; + virtual const pg_info_t &get_shard_info(pg_shard_t peer) const { + if (peer == primary_shard()) { + return get_info(); + } else { + map::const_iterator i = + get_shard_info().find(peer); + assert(i != get_shard_info().end()); + return i->second; + } + } - virtual const pg_missing_t &get_local_missing() const = 0; virtual const PGLog &get_log() const = 0; virtual bool pgb_is_primary() const = 0; virtual OSDMapRef pgb_get_osdmap() const = 0;