From: Sage Weil Date: Mon, 20 Feb 2017 12:45:32 +0000 (-0500) Subject: osd: warn on ops directed to the wrong pg_t X-Git-Tag: v12.0.1~278^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fce285a5ffbcfbd36c9ac525af953ab4bd7d32c6;p=ceph.git osd: warn on ops directed to the wrong pg_t 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 --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 2ed79b3f3e5e4..0b52e247327de 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 671e0ecc26275..3be67054e7e05 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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;