From 93f27942335bb7a5b95f4026e2ece78742be35e4 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Fri, 10 May 2013 15:59:10 -0700 Subject: [PATCH] Throttle: move start_op() to C_SimpleThrottle constructor This is done by all callers right before constructing this. Since C_SimpleThrottle is already responsible for calling ->end_op(), it makes sense to call start_op() there too. Signed-off-by: Josh Durgin --- src/common/Throttle.h | 4 +++- src/librbd/internal.cc | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 192a65a072f8..6d039888c633 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -88,7 +88,9 @@ private: class C_SimpleThrottle : public Context { public: - C_SimpleThrottle(SimpleThrottle *throttle) : m_throttle(throttle) {} + C_SimpleThrottle(SimpleThrottle *throttle) : m_throttle(throttle) { + m_throttle->start_op(); + } virtual void finish(int r) { m_throttle->end_op(r); } diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 66720ec7d80b..d845886b25f9 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -169,7 +169,6 @@ namespace librbd { ldout(cct, 2) << "trim_image objects " << delete_start << " to " << (num_objects - 1) << dendl; for (uint64_t i = delete_start; i < num_objects; ++i) { - throttle.start_op(); string oid = ictx->get_object_name(i); Context *req_comp = new C_SimpleThrottle(&throttle); librados::AioCompletion *rados_completion = @@ -190,7 +189,6 @@ namespace librbd { for (vector::iterator p = extents.begin(); p != extents.end(); ++p) { ldout(ictx->cct, 20) << " ex " << *p << dendl; - throttle.start_op(); Context *req_comp = new C_SimpleThrottle(&throttle); librados::AioCompletion *rados_completion = librados::Rados::aio_create_completion(req_comp, NULL, rados_ctx_cb); @@ -339,7 +337,6 @@ namespace librbd { for (uint64_t i = 0; i < numseg; i++) { string oid = ictx->get_object_name(i); - throttle.start_op(); Context *req_comp = new C_SimpleThrottle(&throttle); librados::AioCompletion *rados_completion = librados::Rados::aio_create_completion(req_comp, NULL, rados_ctx_cb); @@ -2142,7 +2139,6 @@ reprotect_and_return_err: bufferlist bl; string oid = ictx->get_object_name(ono); - throttle.start_op(); Context *comp = new C_SimpleThrottle(&throttle); AioWrite *req = new AioWrite(ictx, oid, ono, 0, objectx, object_overlap, bl, snapc, CEPH_NOSNAP, comp); -- 2.47.3