From a60d5fab0bcc89496efbfb8641ab40d9426ff86e Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 10 Feb 2015 15:42:24 -0800 Subject: [PATCH] objecter: remove dead race handling code The only caller of _get_osd_session() holds rwlock for write, so _get_session() cannot race. The only caller of _get_session() which may possibly race is _op_submit(), which handles the race more simply inline. Call _get_session() inline in place of _get_osd_session(), and remove the unused functions _get_osd_session() and _promote_lock_check_race(). Signed-off-by: Josh Durgin --- src/osdc/Objecter.cc | 35 +++-------------------------------- src/osdc/Objecter.h | 2 -- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index ee5c969ab33..edc1a1b50bd 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2624,31 +2624,6 @@ void Objecter::_session_command_op_assign(OSDSession *to, CommandOp *op) ldout(cct, 15) << __func__ << " " << to->osd << " " << op->tid << dendl; } -int Objecter::_get_osd_session(int osd, RWLock::Context& lc, OSDSession **psession) -{ - int r; - do { - r = _get_session(osd, psession, lc); - if (r == -EAGAIN) { - assert(!lc.is_wlocked()); - - if (!_promote_lock_check_race(lc)) { - return r; - } - } - } while (r == -EAGAIN); - assert(r == 0); - - return 0; -} - -bool Objecter::_promote_lock_check_race(RWLock::Context& lc) -{ - epoch_t epoch = osdmap->get_epoch(); - lc.promote(); - return (epoch == osdmap->get_epoch()); -} - int Objecter::_recalc_linger_op_target(LingerOp *linger_op, RWLock::Context& lc) { assert(rwlock.is_wlocked()); @@ -2659,13 +2634,9 @@ int Objecter::_recalc_linger_op_target(LingerOp *linger_op, RWLock::Context& lc) << " pgid " << linger_op->target.pgid << " acting " << linger_op->target.acting << dendl; - OSDSession *s; - r = _get_osd_session(linger_op->target.osd, lc, &s); - if (r < 0) { - // We have no session for the new destination for the op, so leave it - // in this session to be handled again next time we scan requests - return r; - } + OSDSession *s = NULL; + r = _get_session(linger_op->target.osd, &s, lc); + assert(r == 0); if (linger_op->session != s) { // NB locking two sessions (s and linger_op->session) at the same time here diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index a447c3e365e..3c033f351a9 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1741,7 +1741,6 @@ public: void _session_command_op_assign(OSDSession *to, CommandOp *op); void _session_command_op_remove(OSDSession *from, CommandOp *op); - int _get_osd_session(int osd, RWLock::Context& lc, OSDSession **psession); int _assign_op_target_session(Op *op, RWLock::Context& lc, bool src_session_locked, bool dst_session_locked); int _recalc_linger_op_target(LingerOp *op, RWLock::Context& lc); @@ -1929,7 +1928,6 @@ private: int pool_snap_get_info(int64_t poolid, snapid_t snap, pool_snap_info_t *info); int pool_snap_list(int64_t poolid, vector *snaps); private: - bool _promote_lock_check_race(RWLock::Context& lc); // low-level ceph_tid_t _op_submit(Op *op, RWLock::Context& lc);