From 0debfe11860feadbd5b1bb1dd528ea7615a1f4d3 Mon Sep 17 00:00:00 2001 From: Somnath Roy Date: Fri, 27 Jun 2014 10:48:28 -0700 Subject: [PATCH] OSD: pass param by ref to avoid copying overrhead passing OpRequestRef, OSDMapRef by ref to avoid refcounting overhead and in some cases passing structures by const ref. Signed-off-by: Somnath Roy --- src/osd/OSD.cc | 12 ++++++------ src/osd/OSD.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d3b496f69a6c9..985ce5d0a3a40 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2032,7 +2032,7 @@ PG *OSD::_create_lock_pg( return pg; } -PG *OSD::get_pg_or_queue_for_pg(spg_t pgid, OpRequestRef op) +PG *OSD::get_pg_or_queue_for_pg(const spg_t& pgid, OpRequestRef& op) { RWLock::RLocker l(pg_map_lock); Session *session = static_cast( @@ -5278,7 +5278,7 @@ void OSD::dispatch_op(OpRequestRef op) } } -bool OSD::dispatch_op_fast(OpRequestRef op, OSDMapRef osdmap) { +bool OSD::dispatch_op_fast(OpRequestRef& op, OSDMapRef& osdmap) { if (is_stopping()) { // we're shutting down, so drop the op return true; @@ -7873,7 +7873,7 @@ struct send_map_on_destruct { } }; -void OSD::handle_op(OpRequestRef op, OSDMapRef osdmap) +void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap) { MOSDOp *m = static_cast(op->get_req()); assert(m->get_header().type == CEPH_MSG_OSD_OP); @@ -8021,7 +8021,7 @@ void OSD::handle_op(OpRequestRef op, OSDMapRef osdmap) } template -void OSD::handle_replica_op(OpRequestRef op, OSDMapRef osdmap) +void OSD::handle_replica_op(OpRequestRef& op, OSDMapRef& osdmap) { T *m = static_cast(op->get_req()); assert(m->get_header().type == MSGTYPE); @@ -8079,7 +8079,7 @@ bool OSD::op_is_discardable(MOSDOp *op) return false; } -void OSD::enqueue_op(PG *pg, OpRequestRef op) +void OSD::enqueue_op(PG *pg, OpRequestRef& op) { utime_t latency = ceph_clock_now(cct) - op->get_req()->get_recv_stamp(); dout(15) << "enqueue_op " << op << " prio " << op->get_req()->get_priority() @@ -8415,7 +8415,7 @@ void OSD::set_disk_tp_priority() // -------------------------------- -int OSD::init_op_flags(OpRequestRef op) +int OSD::init_op_flags(OpRequestRef& op) { MOSDOp *m = static_cast(op->get_req()); vector::iterator iter; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 428f903bb6196..dba8529af937c 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -956,7 +956,7 @@ protected: void tick(); void _dispatch(Message *m); void dispatch_op(OpRequestRef op); - bool dispatch_op_fast(OpRequestRef op, OSDMapRef osdmap); + bool dispatch_op_fast(OpRequestRef& op, OSDMapRef& osdmap); void check_osdmap_features(ObjectStore *store); @@ -1507,7 +1507,7 @@ private: } op_shardedwq; - void enqueue_op(PG *pg, OpRequestRef op); + void enqueue_op(PG *pg, OpRequestRef& op); void dequeue_op( PGRef pg, OpRequestRef op, ThreadPool::TPHandle &handle); @@ -1633,7 +1633,7 @@ protected: PGPool _get_pool(int id, OSDMapRef createmap); - PG *get_pg_or_queue_for_pg(spg_t pgid, OpRequestRef op); + PG *get_pg_or_queue_for_pg(const spg_t& pgid, OpRequestRef& op); bool _have_pg(spg_t pgid); PG *_lookup_lock_pg_with_map_lock_held(spg_t pgid); PG *_lookup_lock_pg(spg_t pgid); @@ -2298,10 +2298,10 @@ public: void handle_rep_scrub(MOSDRepScrub *m); void handle_scrub(struct MOSDScrub *m); void handle_osd_ping(class MOSDPing *m); - void handle_op(OpRequestRef op, OSDMapRef osdmap); + void handle_op(OpRequestRef& op, OSDMapRef& osdmap); template - void handle_replica_op(OpRequestRef op, OSDMapRef osdmap); + void handle_replica_op(OpRequestRef& op, OSDMapRef& osdmap); /// check if we can throw out op from a disconnected client static bool op_is_discardable(class MOSDOp *m); @@ -2309,7 +2309,7 @@ public: public: void force_remount(); - int init_op_flags(OpRequestRef op); + int init_op_flags(OpRequestRef& op); OSDService service; friend class OSDService; -- 2.39.5