]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
objectcacher: introduce ObjectCacher::flush_all()
authorYan, Zheng <zyan@redhat.com>
Wed, 28 Oct 2015 09:06:59 +0000 (17:06 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 24 Dec 2015 07:54:40 +0000 (15:54 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 85c5a9b4b25aaf9d462ba61526571014cd73cc14..0324fcc0066311b834046084afd7aca180cd2242 100644 (file)
@@ -1922,6 +1922,46 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv,
   return _flush_set_finish(&gather, onfinish);
 }
 
+// flush all dirty data.  non-blocking, takes callback.
+// returns true if already flushed
+bool ObjectCacher::flush_all(Context *onfinish)
+{
+  assert(lock.is_locked());
+  assert(onfinish != NULL);
+
+  ldout(cct, 10) << "flush_all " << dendl;
+
+  // we'll need to wait for all objects to flush!
+  C_GatherBuilder gather(cct);
+  set<Object*> waitfor_commit;
+
+  set<BufferHead*, BufferHead::ptr_lt>::iterator next, it;
+  next = it = dirty_or_tx_bh.begin();
+  while (it != dirty_or_tx_bh.end()) {
+    ++next;
+    BufferHead *bh = *it;
+    waitfor_commit.insert(bh->ob);
+
+    if (bh->is_dirty())
+      bh_write(bh);
+
+    it = next;
+  }
+
+  for (set<Object*>::iterator i = waitfor_commit.begin();
+       i != waitfor_commit.end();
+       ++i) {
+    Object *ob = *i;
+
+    // we'll need to gather...
+    ldout(cct, 10) << "flush_all will wait for ack tid "
+                  << ob->last_write_tid << " on " << *ob << dendl;
+    ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub());
+  }
+
+  return _flush_set_finish(&gather, onfinish);
+}
+
 void ObjectCacher::purge_set(ObjectSet *oset)
 {
   assert(lock.is_locked());
index aa9438b8ebbcf788d512248a638a29231f30ebbf..dee6fd73c5a828654a0aa83c978dcc4143b1aae0 100644 (file)
@@ -690,7 +690,7 @@ public:
   bool flush_set(ObjectSet *oset, Context *onfinish=0);
   bool flush_set(ObjectSet *oset, vector<ObjectExtent>& ex,
                 Context *onfinish = 0);
-  void flush_all(Context *onfinish = 0);
+  bool flush_all(Context *onfinish = 0);
 
   void purge_set(ObjectSet *oset);