From 90f035629f33e54fe21af0a36a84b89139d99373 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 4 Nov 2020 11:40:18 +0800 Subject: [PATCH] crimson/osd: move PG::with_locked_obc() into .cc Signed-off-by: Kefu Chai --- src/crimson/osd/pg.cc | 17 +++++++++++++++++ src/crimson/osd/pg.h | 18 +++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index eab8452b8d5e8..f05d6f4d6979e 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -865,6 +865,23 @@ PG::load_head_obc(ObjectContextRef obc) }); } +PG::load_obc_ertr::future<> +PG::with_locked_obc(Ref &m, const OpInfo &op_info, + Operation *op, PG::with_obc_func_t &&f) +{ + if (__builtin_expect(stopping, false)) { + throw crimson::common::system_shutdown_exception(); + } + RWState::State type = get_lock_type(op_info); + return get_locked_obc(op, get_oid(*m), type) + .safe_then([f=std::move(f), type=type](auto obc) { + return f(obc).finally([obc, type=type] { + obc->put_lock_type(type); + return load_obc_ertr::now(); + }); + }); +} + PG::load_obc_ertr::future PG::get_locked_obc( Operation *op, const hobject_t &oid, RWState::State type) diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 930aa5e73d913..9cd17c5054a26 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -513,24 +513,12 @@ public: const hobject_t &oid, RWState::State type); public: - template - auto with_locked_obc( + using with_obc_func_t = std::function (ObjectContextRef)>; + load_obc_ertr::future<> with_locked_obc( Ref &m, const OpInfo &op_info, Operation *op, - F &&f) { - if (__builtin_expect(stopping, false)) { - throw crimson::common::system_shutdown_exception(); - } - RWState::State type = get_lock_type(op_info); - return get_locked_obc(op, get_oid(*m), type) - .safe_then([f=std::forward(f), type=type](auto obc) { - return f(obc).finally([obc, type=type] { - obc->put_lock_type(type); - return load_obc_ertr::now(); - }); - }); - } + with_obc_func_t&& f); seastar::future<> handle_rep_op(Ref m); void handle_rep_op_reply(crimson::net::Connection* conn, -- 2.39.5