]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectCacher: deduplicate final part of flush_set()
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 1 Apr 2013 21:51:46 +0000 (14:51 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 10 Apr 2013 18:47:20 +0000 (11:47 -0700)
Both versions of flush_set() did the same thing. Move it into a
helper called from both.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 18a85c0b866560de2a9b9e87a5f825db2128c078..92f0d502746612395c04bdd37dbd04ee8f3ee050 100644 (file)
@@ -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<ObjectExtent>& 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<ObjectExtent>& 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)
index 681b02406fa3601f6f4d25b093f8568d7a95fa09..a17046f9126896231e088647ea1117a07c515365 100644 (file)
@@ -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);