]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/Nestore: batch cleanup
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Mon, 27 Apr 2015 07:49:28 +0000 (15:49 +0800)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:40 +0000 (13:39 -0400)
batch cleanup wal.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/os/newstore/NewStore.cc
src/os/newstore/NewStore.h

index 17109ba9645f8fc972c7260e7eeeb4ed90824910..44bdbe0882aecca5e13b665bce14219dd0dbb0f1 100644 (file)
@@ -2359,7 +2359,8 @@ void NewStore::_kv_sync_thread()
   kv_lock.Lock();
   while (true) {
     assert(kv_committing.empty());
-    if (kv_queue.empty()) {
+    assert(wal_cleaning.empty());
+    if (kv_queue.empty() && wal_cleanup_queue.empty()) {
       if (kv_stop)
        break;
       dout(20) << __func__ << " sleep" << dendl;
@@ -2367,20 +2368,37 @@ void NewStore::_kv_sync_thread()
       kv_cond.Wait(kv_lock);
       dout(20) << __func__ << " wake" << dendl;
     } else {
-      dout(20) << __func__ << " committing " << kv_queue.size() << dendl;
+      dout(20) << __func__ << " committing " << kv_queue.size() << " cleaning " << wal_cleanup_queue.size() << dendl;
       kv_committing.swap(kv_queue);
+      wal_cleaning.swap(wal_cleanup_queue);
       utime_t start = ceph_clock_now(NULL);
       kv_lock.Unlock();
-      db->submit_transaction_sync(db->get_transaction());
+      KeyValueDB::Transaction txc_cleanup_sync = db->get_transaction();
+      //adding wal cleanup op
+      for (std::deque<TransContext *>::iterator it = wal_cleaning.begin();
+           it != wal_cleaning.end();
+           it++) {
+       wal_transaction_t& wt =*(*it)->wal_txn;
+       string key;
+       get_wal_key(wt.seq, &key);
+       txc_cleanup_sync->rmkey(PREFIX_WAL, key);
+      }
+
+      db->submit_transaction_sync(txc_cleanup_sync);
       utime_t finish = ceph_clock_now(NULL);
       utime_t dur = finish - start;
-      dout(20) << __func__ << " committed " << kv_committing.size()
+      dout(20) << __func__ << " committed " << kv_committing.size() << "cleaned " << wal_cleaning.size()
               << " in " << dur << dendl;
       while (!kv_committing.empty()) {
        TransContext *txc = kv_committing.front();
        _txc_state_proc(txc);
        kv_committing.pop_front();
       }
+      while (!wal_cleaning.empty()) {
+       TransContext *txc = wal_cleaning.front();
+       _txc_state_proc(txc);
+       wal_cleaning.pop_front();
+      }
 
       // this is as good a place as any ...
       _reap_collections();
@@ -2420,16 +2438,9 @@ int NewStore::_wal_finish(TransContext *txc)
   wal_transaction_t& wt = *txc->wal_txn;
   dout(20) << __func__ << " txc " << " seq " << wt.seq << txc << dendl;
 
-  string key;
-  get_wal_key(wt.seq, &key);
-  KeyValueDB::Transaction cleanup = db->get_transaction();
-  cleanup->rmkey(PREFIX_WAL, key);
-
-  txc->state = TransContext::STATE_WAL_CLEANUP;
-
   Mutex::Locker l(kv_lock);
-  db->submit_transaction(cleanup);
-  kv_queue.push_back(txc);
+  txc->state = TransContext::STATE_WAL_CLEANUP;
+  wal_cleanup_queue.push_back(txc);
   kv_cond.SignalOne();
   return 0;
 }
index 55b73f7fd0b9ea6a05f8fb34bc8b1a8a4a8298da..ce6dfac17d04b586996f2e1cd2a7670bf1d8a2cb 100644 (file)
@@ -499,6 +499,7 @@ private:
   Cond kv_cond, kv_sync_cond;
   bool kv_stop;
   deque<TransContext*> kv_queue, kv_committing;
+  deque<TransContext*> wal_cleanup_queue, wal_cleaning;
 
   Logger *logger;