Skip to content

Commit

Permalink
Merge pull request #8378 from liewegas/wip-pgls-pgid
Browse files Browse the repository at this point in the history
osdc/Objecter: use full pgid hash in PGNLS ops

Reviewed-by: Josh Durgin <jdurgin@redhat.com>
  • Loading branch information
liewegas committed Apr 4, 2016
2 parents 72f18a2 + f713766 commit 0f81ac5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
30 changes: 24 additions & 6 deletions src/osd/ReplicatedPG.cc
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion src/osdc/Objecter.cc
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/Makefile-client.am
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions src/test/librados/list.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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<const char*> 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();
}
1 change: 1 addition & 0 deletions src/test/librados/tier.cc
Expand Up @@ -5354,6 +5354,7 @@ int main(int argc, char **argv)

vector<const char*> 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);
Expand Down

0 comments on commit 0f81ac5

Please sign in to comment.