From 660e21ea6f8ca3c0bdfed95880db955aa68a4483 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 12 Aug 2015 11:40:40 -0700 Subject: [PATCH] rgw: return error if any spawned op errored Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_coroutine.cc | 18 ++++++++++++++++++ src/rgw/rgw_coroutine.h | 4 ++++ src/rgw/rgw_sync.cc | 8 +++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_coroutine.cc b/src/rgw/rgw_coroutine.cc index 822b0b5113ed7..133897ae67155 100644 --- a/src/rgw/rgw_coroutine.cc +++ b/src/rgw/rgw_coroutine.cc @@ -238,6 +238,9 @@ void RGWCoroutine::call(RGWCoroutine *op) void RGWCoroutine::spawn(RGWCoroutine *op) { + op->get(); + spawned_ops.push_back(op); + RGWCoroutinesStack *stack = env->manager->allocate_stack(); int r = stack->call(op, 0); @@ -248,6 +251,21 @@ void RGWCoroutine::spawn(RGWCoroutine *op) env->stack->set_blocked_by(stack); } +int RGWCoroutine::complete_spawned() +{ + int ret = 0; + for (list::iterator iter = spawned_ops.begin(); iter != spawned_ops.end(); ++iter) { + int r = (*iter)->get_ret_status(); + if (r < 0) { + ret = r; + } + + (*iter)->put(); + } + spawned_ops.clear(); + return ret; +} + int RGWSimpleCoroutine::operate() { reenter(this) { diff --git a/src/rgw/rgw_coroutine.h b/src/rgw/rgw_coroutine.h index e1ef7570d396c..99e7a39af3012 100644 --- a/src/rgw/rgw_coroutine.h +++ b/src/rgw/rgw_coroutine.h @@ -73,6 +73,8 @@ protected: stringstream error_stream; + list spawned_ops; + int set_state(int s, int ret = 0) { state = s; return ret; @@ -91,6 +93,8 @@ protected: void call(RGWCoroutine *op); void spawn(RGWCoroutine *op); + int complete_spawned(); + public: RGWCoroutine(CephContext *_cct) : cct(_cct), env(NULL), blocked(false), retcode(0), state(RGWCoroutine_Run) {} virtual ~RGWCoroutine() {} diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index c14e01edb983c..8c6d29e98339e 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -743,6 +743,7 @@ public: obj_ctx(_obj_ctx), global_status(_gs) {} int handle_data(RGWMetaSyncGlobalStatus& data); + int finish(); }; int RGWReadSyncStatusCoroutine::handle_data(RGWMetaSyncGlobalStatus& data) @@ -755,11 +756,16 @@ int RGWReadSyncStatusCoroutine::handle_data(RGWMetaSyncGlobalStatus& data) char buf[mdlog_sync_status_shard_prefix.size() + 16]; snprintf(buf, sizeof(buf), "%s.%d", mdlog_sync_status_shard_prefix.c_str(), i); spawn(new RGWSimpleRadosReadCR(async_rados, store, obj_ctx, store->get_zone_params().log_pool, - buf, &sync_marker)); + buf, &sync_marker)); } return 0; } +int RGWReadSyncStatusCoroutine::finish() +{ + return complete_spawned(); +} + class RGWCloneMetaLogCoroutine : public RGWCoroutine { RGWRados *store; RGWMetadataLog *mdlog; -- 2.39.5