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)
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...