From: Yan, Zheng Date: Wed, 28 Oct 2015 09:06:59 +0000 (+0800) Subject: objectcacher: introduce ObjectCacher::flush_all() X-Git-Tag: v10.0.3~120^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bd86c301a54a6e23cf2ce257b8024b6b92dfbe11;p=ceph.git objectcacher: introduce ObjectCacher::flush_all() Signed-off-by: Yan, Zheng --- diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index 85c5a9b4b25..0324fcc0066 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -1922,6 +1922,46 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector& 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 waitfor_commit; + + set::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::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()); diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index aa9438b8ebb..dee6fd73c5a 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -690,7 +690,7 @@ public: bool flush_set(ObjectSet *oset, Context *onfinish=0); bool flush_set(ObjectSet *oset, vector& ex, Context *onfinish = 0); - void flush_all(Context *onfinish = 0); + bool flush_all(Context *onfinish = 0); void purge_set(ObjectSet *oset);