From 75950ac1f2cc47de2a66614ed5d11ebab0dbf262 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 6 Jul 2011 12:35:26 -0700 Subject: [PATCH] rados_list_parallel: try to handle consistency issues Signed-off-by: Colin McCabe --- src/test/system/rados_list_parallel.cc | 27 +++++++++++++++++++++----- src/test/system/systest_runnable.h | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/test/system/rados_list_parallel.cc b/src/test/system/rados_list_parallel.cc index 78af6ae84a015..15ad6136b7e43 100644 --- a/src/test/system/rados_list_parallel.cc +++ b/src/test/system/rados_list_parallel.cc @@ -95,6 +95,22 @@ public: } }; +/* Rados doesn't have read-after-write consistency for pool creation events. + * What this means is that even after the first process has created the pool, + * we may have to wait a while before we're able to see it. We will be able to + * see it when a new OSDMap arrives. + */ +static int do_ioctx_create(const char *id_str, rados_t &cl, + const char *pool_name, rados_ioctx_t &io_ctx) +{ + int ret = rados_pool_create(cl, "foo"); + if (ret != -EEXIST) { + return ret; + } + ret = rados_ioctx_create(cl, "foo", &io_ctx); + return ret; +} + class RadosListObjectsR : public SysTestRunnable { public: @@ -116,13 +132,14 @@ public: pool_setup_sem->wait(); rados_ioctx_t io_ctx; - RETURN_IF_NONZERO(rados_ioctx_create(cl, "foo", &io_ctx)); + printf("%s: do_ioctx_create.\n", get_id_str()); + RETURN_IF_NONZERO(do_ioctx_create(get_id_str(), cl, "foo", io_ctx)); // int ret, saw = 0; // const char *obj_name; // char tmp[RLP_OBJECT_SZ_MAX]; -// rados_list_ctx_t h; -// RETURN_IF_NONZERO(rados_objects_list_open(io_ctx, &h)); + rados_list_ctx_t h; + RETURN_IF_NONZERO(rados_objects_list_open(io_ctx, &h)); // printf("%s: listing objects.\n", get_id_str()); // while (true) { // ret = rados_objects_list_next(h, &obj_name); @@ -143,7 +160,7 @@ public: //// if (saw == RLP_NUM_OBJECTS / 2) //// modify_sem->wait(); // } -// rados_objects_list_close(h); + rados_objects_list_close(h); //printf("%s: saw %d objects\n", get_id_str(), saw); @@ -175,7 +192,7 @@ public: pool_setup_sem->wait(); rados_ioctx_t io_ctx; - RETURN_IF_NONZERO(rados_ioctx_create(cl, "foo", &io_ctx)); + RETURN_IF_NONZERO(do_ioctx_create(get_id_str(), cl, "foo", io_ctx)); std::vector to_delete; for (int i = 0; i < RLP_NUM_OBJECTS; ++i) { diff --git a/src/test/system/systest_runnable.h b/src/test/system/systest_runnable.h index f8077f9562940..e64e056f7d503 100644 --- a/src/test/system/systest_runnable.h +++ b/src/test/system/systest_runnable.h @@ -23,7 +23,7 @@ #define RETURN_IF_NOT_VAL(expected, expr) \ do {\ int _rinv_ret = expr;\ - if (_rinv_ret) {\ + if (_rinv_ret != expected) {\ printf("%s: file %s, line %d: expected %d, got %d",\ get_id_str(), __FILE__, __LINE__, expected, _rinv_ret);\ return _rinv_ret;\ -- 2.39.5