diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index abefb0066c74b..3958f8942ea57 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -925,8 +925,10 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) // fall through case CEPH_OSD_OP_PGNLS: - if (m->get_pg() != info.pgid.pgid) { - dout(10) << " pgnls pg=" << m->get_pg() << " != " << info.pgid << dendl; + if (get_osdmap()->raw_pg_to_pg(m->get_pg()) != info.pgid.pgid) { + dout(10) << " pgnls pg=" << m->get_pg() + << " " << get_osdmap()->raw_pg_to_pg(m->get_pg()) + << " != " << info.pgid << dendl; result = 0; // hmm? } else { unsigned list_size = MIN(cct->_conf->osd_max_pgls, p->op.pgls.count); @@ -946,7 +948,21 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) hobject_t next; hobject_t lower_bound = response.handle; - dout(10) << " pgnls lower_bound " << lower_bound << dendl; + hobject_t pg_start = info.pgid.pgid.get_hobj_start(); + hobject_t pg_end = info.pgid.pgid.get_hobj_end(pool.info.get_pg_num()); + dout(10) << " pgnls lower_bound " << lower_bound + << " pg_end " << pg_end << dendl; + if (get_sort_bitwise() && + ((lower_bound != hobject_t::get_max() && + cmp_bitwise(lower_bound, pg_end) >= 0) || + (lower_bound != hobject_t() && + cmp_bitwise(lower_bound, pg_start) < 0))) { + // this should only happen with a buggy client. + dout(10) << "outside of PG bounds " << pg_start << " .. " + << pg_end << dendl; + result = -EINVAL; + break; + } hobject_t current = lower_bound; osr->flush(); @@ -1081,7 +1097,7 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) } else { response.handle = next; } - dout(10) << "pgls handle=" << response.handle << dendl; + dout(10) << "pgnls handle=" << response.handle << dendl; ::encode(response, osd_op.outdata); if (filter) ::encode(filter_out, osd_op.outdata); @@ -1113,8 +1129,10 @@ void ReplicatedPG::do_pg_op(OpRequestRef op) // fall through case CEPH_OSD_OP_PGLS: - if (m->get_pg() != info.pgid.pgid) { - dout(10) << " pgls pg=" << m->get_pg() << " != " << info.pgid << dendl; + if (get_osdmap()->raw_pg_to_pg(m->get_pg()) != info.pgid.pgid) { + dout(10) << " pgls pg=" << m->get_pg() + << " " << get_osdmap()->raw_pg_to_pg(m->get_pg()) + << " != " << info.pgid << dendl; result = 0; // hmm? } else { unsigned list_size = MIN(cct->_conf->osd_max_pgls, p->op.pgls.count); diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index d184b446b3679..b208254eba683 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2663,7 +2663,15 @@ int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend, t->osd = -1; return RECALC_OP_TARGET_POOL_DNE; } - pgid = osdmap->raw_pg_to_pg(t->base_pgid); + if (osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) { + // if the SORTBITWISE flag is set, we know all OSDs are running + // jewel+. + pgid = t->base_pgid; + } else { + // legacy behavior. pre-jewel OSDs will fail if we send a + // full-hash pgid value. + pgid = osdmap->raw_pg_to_pg(t->base_pgid); + } } else { int ret = osdmap->object_locator_to_pg(t->target_oid, t->target_oloc, pgid); diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am index 2d3ac226b9381..243c2b069d7ed 100644 --- a/src/test/Makefile-client.am +++ b/src/test/Makefile-client.am @@ -234,7 +234,7 @@ ceph_test_rados_api_aio_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_rados_api_aio ceph_test_rados_api_list_SOURCES = test/librados/list.cc -ceph_test_rados_api_list_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) +ceph_test_rados_api_list_LDADD = $(LIBRADOS) $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) $(CEPH_GLOBAL) ceph_test_rados_api_list_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_rados_api_list diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc index b7f0253671281..60b97b52ea481 100644 --- a/src/test/librados/list.cc +++ b/src/test/librados/list.cc @@ -5,6 +5,10 @@ #include "include/stringify.h" #include "test/librados/test.h" #include "test/librados/TestCase.h" +#include "global/global_context.h" +#include "global/global_init.h" +#include "common/ceph_argparse.h" +#include "common/common_init.h" #include "include/types.h" #include "common/hobject.h" @@ -956,3 +960,18 @@ TEST_F(LibRadosListPP, EnumerateObjectsFilterPP) { #pragma GCC diagnostic pop #pragma GCC diagnostic warning "-Wpragmas" + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + + vector args; + argv_to_vec(argc, (const char **)argv, args); + env_to_vec(args); + cout << args << std::endl; + + global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + common_init_finish(g_ceph_context); + + return RUN_ALL_TESTS(); +} diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 0ff1c946b20da..3f9a5b33d1045 100755 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -5354,6 +5354,7 @@ int main(int argc, char **argv) vector args; argv_to_vec(argc, (const char **)argv, args); + env_to_vec(args), global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context);