]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
hammer: objectcacher: introduce ObjectCacher::flush_all()
authorYan, Zheng <zyan@redhat.com>
Wed, 28 Oct 2015 09:06:59 +0000 (17:06 +0800)
committerAlexey Sheplyakov <asheplyakov@mirantis.com>
Mon, 21 Nov 2016 15:37:26 +0000 (18:37 +0300)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit bd86c301a54a6e23cf2ce257b8024b6b92dfbe11)

Conflicts:
src/osdc/ObjectCacher.h - whitespace only changes

Semantic conflicts:
        ObjectCacher::flush_all(): dirty_or_tx_bh is a set<BufferHead *>
in Hammer

src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index b2c257237628126acf218df179c0c3f079413a56..abac935d6020a9213821afe0cb6c26e2cf870b02 100644 (file)
@@ -1789,6 +1789,46 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv, Context
   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*>::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 0bef597fdf65b88b252a7c4c761006aeeb70a155..8f735cb06fcd38afc30dd800e8df87e3736c1f2f 100644 (file)
@@ -618,7 +618,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);