]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: warn on ops directed to the wrong pg_t
authorSage Weil <sage@redhat.com>
Mon, 20 Feb 2017 12:45:32 +0000 (07:45 -0500)
committerSage Weil <sage@redhat.com>
Thu, 23 Feb 2017 15:29:42 +0000 (10:29 -0500)
Check whether the request hobj maps to the current pg_t.  If we have the
osd_debug_misdirected_ops setting enabled (as teuthology does), assert out
as well so that the error is easy to spot.  This catches bugs in the
Objecter (especially the new code that explicitly names the spg_t for the
request).

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/PrimaryLogPG.cc
src/osd/osd_types.h

index 2ed79b3f3e5e455703fbcd1839a0c6a8740a80d3..0b52e247327de3635ae63ab95f026e20cec4f621 100644 (file)
@@ -1713,6 +1713,17 @@ void PrimaryLogPG::do_op(OpRequestRef& op)
   hobject_t head = m->get_hobj();
   head.snap = CEPH_NOSNAP;
 
+  if (!info.pgid.pgid.contains(
+       info.pgid.pgid.get_split_bits(pool.info.get_pg_num()), head)) {
+    derr << __func__ << " " << info.pgid.pgid << " does not contain "
+        << head << " pg_num " << pool.info.get_pg_num() << " hash "
+        << std::hex << head.get_hash() << std::dec << dendl;
+    osd->clog->warn() << info.pgid.pgid << " does not contain " << head
+                     << " op " << *m << "\n";
+    assert(!cct->_conf->osd_debug_misdirected_ops);
+    return;
+  }
+
   bool can_backoff =
     m->get_connection()->has_feature(CEPH_FEATURE_RADOS_BACKOFF);
   SessionRef session;
index 671e0ecc2627576889b039691044bffff9c4bb58..3be67054e7e055dafc88cfac517d5e355bab0b47 100644 (file)
@@ -402,6 +402,9 @@ struct pg_t {
   bool contains(int bits, const ghobject_t& oid) {
     return oid.match(bits, ps());
   }
+  bool contains(int bits, const hobject_t& oid) {
+    return oid.match(bits, ps());
+  }
 
   hobject_t get_hobj_start() const;
   hobject_t get_hobj_end(unsigned pg_num) const;