From f5b81d8d167d1aa7f82a5776bbb1f319063ab809 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 1 Apr 2013 14:51:46 -0700 Subject: [PATCH] ObjectCacher: deduplicate final part of flush_set() Both versions of flush_set() did the same thing. Move it into a helper called from both. Signed-off-by: Josh Durgin --- src/osdc/ObjectCacher.cc | 37 ++++++++++++++++++------------------- src/osdc/ObjectCacher.h | 1 + 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index 18a85c0b86656..92f0d50274661 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -1495,6 +1495,20 @@ bool ObjectCacher::flush(Object *ob, loff_t offset, loff_t length) return clean; } +bool ObjectCacher::_flush_set_finish(C_GatherBuilder *gather, Context *onfinish) +{ + assert(lock.is_locked()); + if (gather->has_subs()) { + gather->set_finisher(onfinish); + gather->activate(); + return false; + } + + ldout(cct, 10) << "flush_set has no dirty|tx bhs" << dendl; + onfinish->complete(0); + return true; +} + // flush. non-blocking, takes callback. // returns true if already flushed bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish) @@ -1526,15 +1540,7 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish) } } - if (gather.has_subs()) { - gather.set_finisher(onfinish); - gather.activate(); - return false; - } else { - ldout(cct, 10) << "flush_set " << oset << " has no dirty|tx bhs" << dendl; - onfinish->complete(0); - return true; - } + return _flush_set_finish(&gather, onfinish); } // flush. non-blocking, takes callback. @@ -1549,7 +1555,8 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector& exv, Context return true; } - ldout(cct, 10) << "flush_set " << oset << " on " << exv.size() << " ObjectExtents" << dendl; + ldout(cct, 10) << "flush_set " << oset << " on " << exv.size() + << " ObjectExtents" << dendl; // we'll need to wait for all objects to flush! C_GatherBuilder gather(cct); @@ -1573,15 +1580,7 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector& exv, Context } } - if (gather.has_subs()) { - gather.set_finisher(onfinish); - gather.activate(); - return false; - } else { - ldout(cct, 10) << "flush_set " << oset << " has no dirty|tx bhs" << dendl; - onfinish->complete(0); - return true; - } + return _flush_set_finish(&gather, onfinish); } void ObjectCacher::purge_set(ObjectSet *oset) diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index 681b02406fa36..a17046f912689 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -573,6 +573,7 @@ private: int _wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset, Mutex& lock, Context *onfreespace); void maybe_wait_for_writeback(uint64_t len); + bool _flush_set_finish(C_GatherBuilder *gather, Context *onfinish); public: bool set_is_cached(ObjectSet *oset); -- 2.39.5