From: Kefu Chai Date: Sat, 19 Sep 2020 03:02:19 +0000 (+0800) Subject: crimson/osd: split PG::get_oid_and_lock() into two methods X-Git-Tag: v16.1.0~1019^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=da32890cf5955700d43833297b413b2dd1e5d83c;p=ceph.git crimson/osd: split PG::get_oid_and_lock() into two methods for better readability Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 3abe129c2fe4..0b225cff604d 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -717,23 +717,24 @@ seastar::future> PG::do_pg_ops(Ref m) }); } -std::pair PG::get_oid_and_lock( - const MOSDOp &m, - const OpInfo &op_info) +hobject_t PG::get_oid(const MOSDOp &m) +{ + return (m.get_snapid() == CEPH_SNAPDIR ? + m.get_hobj().get_head() : + m.get_hobj()); +} + +RWState::State PG::get_lock_type(const OpInfo &op_info) { - auto oid = m.get_snapid() == CEPH_SNAPDIR ? - m.get_hobj().get_head() : m.get_hobj(); - RWState::State lock_type = RWState::RWNONE; if (op_info.rwordered() && op_info.may_read()) { - lock_type = RWState::RWState::RWEXCL; + return RWState::RWEXCL; } else if (op_info.rwordered()) { - lock_type = RWState::RWState::RWWRITE; + return RWState::RWWRITE; } else { ceph_assert(op_info.may_read()); - lock_type = RWState::RWState::RWREAD; + return RWState::RWREAD; } - return std::make_pair(oid, lock_type); } std::optional PG::resolve_oid( diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 7cdd054c33a3..0f1e92417c69 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -482,9 +482,8 @@ public: void handle_activate_map(PeeringCtx &rctx); void handle_initialize(PeeringCtx &rctx); - static std::pair get_oid_and_lock( - const MOSDOp &m, - const OpInfo &op_info); + static hobject_t get_oid(const MOSDOp &m); + static RWState::State get_lock_type(const OpInfo &op_info); static std::optional resolve_oid( const SnapSet &snapset, const hobject_t &oid); @@ -514,8 +513,8 @@ public: if (__builtin_expect(stopping, false)) { throw crimson::common::system_shutdown_exception(); } - auto [oid, type] = get_oid_and_lock(*m, op_info); - return get_locked_obc(op, oid, type) + 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);