From: Sage Weil Date: Tue, 8 Apr 2014 15:52:43 +0000 (-0700) Subject: osd: make misdirected checks explicit about replicas, flags X-Git-Tag: v0.80-rc1~71^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d3833ddafe40889314dec50c1b233af00f1ee6fd;p=ceph.git osd: make misdirected checks explicit about replicas, flags Only allow read ops to target replicas if the necessary op flags are set. The previous checks were very sloppy. Fixes: #8031 Signed-off-by: Sage Weil --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 49503efc0a3c..4102b5156c84 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -4910,16 +4910,26 @@ bool PG::can_discard_op(OpRequestRef op) if (OSD::op_is_discardable(m)) { dout(20) << " discard " << *m << dendl; return true; - } else if ((op->may_write() || op->may_cache()) && - (!is_primary() || - !same_for_modify_since(m->get_map_epoch()))) { - osd->handle_misdirected_op(this, op); - return true; - } else if (op->may_read() && - !same_for_read_since(m->get_map_epoch())) { - osd->handle_misdirected_op(this, op); - return true; - } else if (is_replay()) { + } + if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS | + CEPH_OSD_FLAG_LOCALIZE_READS)) && + op->may_read() && + !(op->may_write() || op->may_cache())) { + // balanced reads; any replica will do + if (!((is_primary() || is_replica()) && + same_for_read_since(m->get_map_epoch()))) { + osd->handle_misdirected_op(this, op); + return true; + } + } else { + // normal case; must be primary + if (!(is_primary() && + same_for_modify_since(m->get_map_epoch()))) { + osd->handle_misdirected_op(this, op); + return true; + } + } + if (is_replay()) { if (m->get_version().version > 0) { dout(7) << " queueing replay at " << m->get_version() << " for " << *m << dendl;