From 901ebb50bd7f78cb157fdb4557d1be70e05ffcdd Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 5 Aug 2015 14:07:08 -0700 Subject: [PATCH] rgw: more simplification create a helper method in the ops manager to run a single op, it builds the needed env Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync.cc | 50 +++++++++++++++++++++------------------------ src/rgw/rgw_sync.h | 2 ++ 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index aa6f89a018855..45783f365df4a 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -857,6 +857,28 @@ int RGWAsyncOpsManager::run(list& stacks) return 0; } +int RGWAsyncOpsManager::run(RGWAsyncOp *op) +{ + list stacks; + RGWAsyncOpsStack *stack = new RGWAsyncOpsStack(cct, this); + int r = stack->call(op); + if (r < 0) { + ldout(cct, 0) << "ERROR: stack->call() returned r=" << r << dendl; + return r; + } + + stacks.push_back(stack); + + r = run(stacks); + if (r < 0) { + ldout(cct, 0) << "ERROR: run(stacks) returned r=" << r << dendl; + } + + delete stack; + + return r; +} + AioCompletionNotifier *RGWAsyncOpsManager::create_completion_notifier(RGWAsyncOpsStack *stack) { return new AioCompletionNotifier(&completion_mgr, (void *)stack); @@ -898,34 +920,8 @@ int RGWRemoteMetaLog::fetch() int RGWRemoteMetaLog::get_sync_status(RGWMetaSyncGlobalStatus *sync_status) { - list stacks; - RGWAsyncOpsStack *stack = new RGWAsyncOpsStack(store->ctx(), this); RGWObjectCtx obj_ctx(store, NULL); - RGWReadSyncStatusOp *op = new RGWReadSyncStatusOp(async_rados, store, obj_ctx, sync_status); - int r = stack->call(op); -#if 0 - int ret = status_manager.read_global_status(); - if (ret < 0) { - ldout(store->ctx(), 0) << "ERROR: status_manager.read_global_status() returned ret=" << ret << dendl; - return ret; - } -#endif - - if (r < 0) { - ldout(store->ctx(), 0) << "ERROR: stack->call() returned r=" << r << dendl; - return r; - } - - stacks.push_back(stack); - - r = run(stacks); - if (r < 0) { - ldout(store->ctx(), 0) << "ERROR: run(stacks) returned r=" << r << dendl; - } - - delete stack; - - return r; + return run(new RGWReadSyncStatusOp(async_rados, store, obj_ctx, sync_status)); } int RGWRemoteMetaLog::get_shard_sync_marker(int shard_id, rgw_sync_marker *shard_status) diff --git a/src/rgw/rgw_sync.h b/src/rgw/rgw_sync.h index bb32422060e92..010f9bdf171c9 100644 --- a/src/rgw/rgw_sync.h +++ b/src/rgw/rgw_sync.h @@ -128,6 +128,8 @@ public: virtual ~RGWAsyncOpsManager() {} int run(list& ops); + int run(RGWAsyncOp *op); + virtual void report_error(RGWAsyncOpsStack *op); AioCompletionNotifier *create_completion_notifier(RGWAsyncOpsStack *stack); -- 2.39.5