From 9196a75459c73f9da27935348abf21ed08be0e60 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Mar 2016 11:43:01 -0400 Subject: [PATCH 1/6] osd/ReplicatedPG: fix typo Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index abefb0066c7..02e36cf542a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1081,7 +1081,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); From f16187f68d7f494fd5ed243e163a8ae3cb111cd3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Mar 2016 11:55:55 -0400 Subject: [PATCH 2/6] osdc/Objecter: use full hash value for pg[n]ls ops Normal ops do this so they can behave when racing with split; pgnls ops are no different. In particular, this fixes a bug where we have an old OSDMap that doesn't reflect a split, and the OSD replies with a 'next' value of the PG's new max. If we resend the same value to that PG, it'll be out of bounds, and BlueStore will notice. Signed-off-by: Sage Weil --- src/osdc/Objecter.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index d184b446b36..b208254eba6 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); From 5c612e82bb88011315aa915646cce29d0496b289 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 31 Mar 2016 10:23:36 -0400 Subject: [PATCH 3/6] osd/ReplicatedPG: discard pgnls op that is outside pg bounds This should only happen with a buggy client, but we should avoid crashing, and send a polite error message back. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 02e36cf542a..e65c0842868 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -946,7 +946,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(); From b9b07c13e42c36938450358eaad0dedc54b9d7c4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 3 Apr 2016 09:35:03 -0400 Subject: [PATCH 4/6] osd/ReplicatedPG: tolerate pgls commands with full hash Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index e65c0842868..3958f8942ea 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); @@ -1127,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); From 769c0affc4408061fa4787c7e910e4f48b9f3bf8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 3 Apr 2016 09:45:23 -0400 Subject: [PATCH 5/6] ceph_test_rados_api_list: parse env Signed-off-by: Sage Weil --- src/test/Makefile-client.am | 2 +- src/test/librados/list.cc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am index 2d3ac226b93..243c2b069d7 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 b7f02536712..60b97b52ea4 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(); +} From f7137661a2c1a0cfe788835c8d1a09d88094430f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 3 Apr 2016 09:49:07 -0400 Subject: [PATCH 6/6] ceph_test_rados_api_tier: parse env Signed-off-by: Sage Weil --- src/test/librados/tier.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 0ff1c946b20..3f9a5b33d10 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);