From: Radoslaw Zarzynski Date: Tue, 16 Mar 2021 12:45:06 +0000 (+0000) Subject: osd: move PrimaryLogPG::get_rw_locks() from header to .cc. X-Git-Tag: v17.1.0~2604^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfca9f8c0d8b0bcec54ef5bbc4ae0fc3ed6bd03a;p=ceph.git osd: move PrimaryLogPG::get_rw_locks() from header to .cc. For the sake of symmetry with `release_object_locks()` and easier grepping for e.g. `ctx->lock_manager`. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index a91ff016f569..95ccf231d0dd 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1610,6 +1610,52 @@ int PrimaryLogPG::do_scrub_ls(const MOSDOp *m, OSDOp *osd_op) return r; } +/** + * Grabs locks for OpContext, should be cleaned up in close_op_ctx + * + * @param ctx [in,out] ctx to get locks for + * @return true on success, false if we are queued + */ +bool PrimaryLogPG::get_rw_locks(bool write_ordered, OpContext *ctx) +{ + /* If head_obc, !obc->obs->exists and we will always take the + * snapdir lock *before* the head lock. Since all callers will do + * this (read or write) if we get the first we will be guaranteed + * to get the second. + */ + if (write_ordered && ctx->op->may_read()) { + ctx->lock_type = RWState::RWEXCL; + } else if (write_ordered) { + ctx->lock_type = RWState::RWWRITE; + } else { + ceph_assert(ctx->op->may_read()); + ctx->lock_type = RWState::RWREAD; + } + + if (ctx->head_obc) { + ceph_assert(!ctx->obc->obs.exists); + if (!ctx->lock_manager.get_lock_type( + ctx->lock_type, + ctx->head_obc->obs.oi.soid, + ctx->head_obc, + ctx->op)) { + ctx->lock_type = RWState::RWNONE; + return false; + } + } + if (ctx->lock_manager.get_lock_type( + ctx->lock_type, + ctx->obc->obs.oi.soid, + ctx->obc, + ctx->op)) { + return true; + } else { + ceph_assert(!ctx->head_obc); + ctx->lock_type = RWState::RWNONE; + return false; + } +} + /** * Releases locks * diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index c08d7445feb8..0321eb9ab34b 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -868,44 +868,7 @@ protected: * @param ctx [in,out] ctx to get locks for * @return true on success, false if we are queued */ - bool get_rw_locks(bool write_ordered, OpContext *ctx) { - /* If head_obc, !obc->obs->exists and we will always take the - * snapdir lock *before* the head lock. Since all callers will do - * this (read or write) if we get the first we will be guaranteed - * to get the second. - */ - if (write_ordered && ctx->op->may_read()) { - ctx->lock_type = RWState::RWEXCL; - } else if (write_ordered) { - ctx->lock_type = RWState::RWWRITE; - } else { - ceph_assert(ctx->op->may_read()); - ctx->lock_type = RWState::RWREAD; - } - - if (ctx->head_obc) { - ceph_assert(!ctx->obc->obs.exists); - if (!ctx->lock_manager.get_lock_type( - ctx->lock_type, - ctx->head_obc->obs.oi.soid, - ctx->head_obc, - ctx->op)) { - ctx->lock_type = RWState::RWNONE; - return false; - } - } - if (ctx->lock_manager.get_lock_type( - ctx->lock_type, - ctx->obc->obs.oi.soid, - ctx->obc, - ctx->op)) { - return true; - } else { - ceph_assert(!ctx->head_obc); - ctx->lock_type = RWState::RWNONE; - return false; - } - } + bool get_rw_locks(bool write_ordered, OpContext *ctx); /** * Cleans up OpContext