]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: add osd_is_valid_op_target()
authorSage Weil <sage@redhat.com>
Thu, 13 Nov 2014 01:04:35 +0000 (17:04 -0800)
committerSage Weil <sage@redhat.com>
Thu, 13 Nov 2014 01:13:06 +0000 (17:13 -0800)
Helper to check whether an osd is a given op target for a pg.  This
assumes that for EC we always send ops to the primary, while for
replicated we may target any replica.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 89c02637914ac7332e9dbdbfefc2049b2b6c127d)

src/osd/OSDMap.h

index a34758369ed328a47d11a9d0c6f466ee08c197ad..b3b7ab6e30461246e471098d7c7239f55be29aa8 100644 (file)
@@ -777,6 +777,18 @@ public:
     return calc_pg_role(osd, group, nrep);
   }
 
+  bool osd_is_valid_op_target(pg_t pg, int osd) const {
+    int primary;
+    vector<int> group;
+    int nrep = pg_to_acting_osds(pg, &group, &primary);
+    if (osd == primary)
+      return true;
+    if (pg_is_ec(pg))
+      return false;
+
+    return calc_pg_role(osd, group, nrep) >= 0;
+  }
+
 
   /*
    * handy helpers to build simple maps...