From: Radoslaw Zarzynski Date: Wed, 27 Nov 2019 15:08:41 +0000 (+0100) Subject: crimson: turn with_effect() into with_effect_on_obc(). X-Git-Tag: v15.1.1~415^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3817d08c8bc524fc3dea425fb65143ef7f8726d;p=ceph.git crimson: turn with_effect() into with_effect_on_obc(). Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/ops_executer.h b/src/crimson/osd/ops_executer.h index 5641a211c89..fe4a56b5f99 100644 --- a/src/crimson/osd/ops_executer.h +++ b/src/crimson/osd/ops_executer.h @@ -66,7 +66,8 @@ private: // the later on `submit_changes()` – after successfully processing main // stages of all involved operations. When any stage fails, none of all // scheduled effect-exposing stages will be executed. - // when operation requires this division, `with_effect()` should be used. + // when operation requires this division, some variant of `with_effect()` + // should be used. struct effect_t { virtual osd_op_errorator::future<> execute() = 0; virtual ~effect_t() = default; @@ -87,7 +88,10 @@ private: seastar::chunked_fifo> op_effects; template - auto with_effect(Context&& ctx, MainFunc&& main_func, EffectFunc&& effect_func); + auto with_effect_on_obc( + Context&& ctx, + MainFunc&& main_func, + EffectFunc&& effect_func); call_errorator::future<> do_op_call(class OSDOp& osd_op); @@ -148,29 +152,35 @@ public: }; template -auto OpsExecuter::with_effect( +auto OpsExecuter::with_effect_on_obc( Context&& ctx, MainFunc&& main_func, EffectFunc&& effect_func) { using context_t = std::decay_t; // the language offers implicit conversion to pointer-to-function for - // lambda only when it's closureless - static_assert(std::is_convertible_v (*)(context_t&&)>, + // lambda only when it's closureless. We enforce this restriction due + // the fact that `submit_changes()` std::moves many executer's parts. + using allowed_effect_func_t = + seastar::future<> (*)(context_t&&, ObjectContextRef); + static_assert(std::is_convertible_v, "with_effect function is not allowed to capture"); struct task_t final : effect_t { context_t ctx; EffectFunc effect_func; + ObjectContextRef obc; - task_t(Context&& ctx, EffectFunc&& effect_func) - : ctx(std::move(ctx)), effect_func(std::move(effect_func)) {} + task_t(Context&& ctx, EffectFunc&& effect_func, ObjectContextRef obc) + : ctx(std::move(ctx)), + effect_func(std::move(effect_func)), + obc(std::move(obc)) { + } osd_op_errorator::future<> execute() final { - return std::move(effect_func)(std::move(ctx)); + return std::move(effect_func)(std::move(ctx), std::move(obc)); } }; auto task = - std::make_unique(std::move(ctx), std::move(effect_func)); + std::make_unique(std::move(ctx), std::move(effect_func), obc); auto& ctx_ref = task->ctx; op_effects.emplace_back(std::move(task)); return std::forward(main_func)(ctx_ref);