]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGBackend: add some additional helpers.
authorSamuel Just <sam.just@inktank.com>
Tue, 28 Jan 2014 00:52:05 +0000 (16:52 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:12:14 +0000 (20:12 -0800)
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 <sam.just@inktank.com>
src/osd/PGBackend.h

index b39a54efe23f5fbd8df8aee4db3271c30cb6e535..5332530fe9bcdd35bc432855fa7116d901f2ea44 100644 (file)
      virtual const map<hobject_t, set<pg_shard_t> > &get_missing_loc_shards()
        const = 0;
 
+     virtual const pg_missing_t &get_local_missing() const = 0;
      virtual const map<pg_shard_t, pg_missing_t> &get_shard_missing()
        const = 0;
+     virtual boost::optional<const pg_missing_t &> maybe_get_shard_missing(
+       pg_shard_t peer) const {
+       if (peer == primary_shard()) {
+        return get_local_missing();
+       } else {
+        map<pg_shard_t, pg_missing_t>::const_iterator i =
+          get_shard_missing().find(peer);
+        if (i == get_shard_missing().end()) {
+          return boost::optional<const pg_missing_t &>();
+        } else {
+          return i->second;
+        }
+       }
+     }
+     virtual const pg_missing_t &get_shard_missing(pg_shard_t peer) const {
+       boost::optional<const pg_missing_t &> m = maybe_get_shard_missing(peer);
+       assert(m);
+       return *m;
+     }
 
      virtual const map<pg_shard_t, pg_info_t> &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<pg_shard_t, pg_info_t>::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;