]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/newstore: let wal cleanup kv txn get batched
authorSage Weil <sage@redhat.com>
Fri, 10 Apr 2015 21:28:13 +0000 (14:28 -0700)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:37 +0000 (13:39 -0400)
No need to trigger another sync kv commit here; just let the next KV
commit catch it.

We could possibly do a bit better here by not waking up the kv thread at
all...

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/newstore/NewStore.cc
src/os/newstore/NewStore.h

index 8989e584bc71dca994e5d73447ed90a34a8c5468..daaee2183ac0540790ea81eb958037d10ca29120 100644 (file)
@@ -2209,7 +2209,19 @@ void NewStore::_kv_sync_thread()
       dout(20) << __func__ << " committed " << kv_committing.size()
               << " in " << dur << dendl;
       while (!kv_committing.empty()) {
-       _txc_finish_kv(kv_committing.front());
+       TransContext *txc = kv_committing.front();
+       if (txc->state == TransContext::STATE_WAL_CLEANUP) {
+         txc->osr->qlock.Lock();
+         txc->state = TransContext::STATE_FINISHING;
+         txc->osr->qlock.Unlock();
+         _txc_finish_apply(txc);
+       } else if (txc->state == TransContext::STATE_KV_QUEUED) {
+         _txc_finish_kv(txc);
+       } else {
+         derr << __func__ << " unexpected txc state " << txc->get_state_name()
+              << dendl;
+         assert(0);
+       }
        kv_committing.pop_front();
       }
 
@@ -2246,13 +2258,15 @@ int NewStore::_apply_wal_transaction(TransContext *txc)
   get_wal_key(wt.seq, &key);
   KeyValueDB::Transaction cleanup = db->get_transaction();
   cleanup->rmkey(PREFIX_WAL, key);
-  db->submit_transaction_sync(cleanup);
 
   txc->osr->qlock.Lock();
-  txc->state = TransContext::STATE_FINISHING;
+  txc->state = TransContext::STATE_WAL_CLEANUP;
   txc->osr->qlock.Unlock();
 
-  _txc_finish_apply(txc);
+  Mutex::Locker l(kv_lock);
+  db->submit_transaction(cleanup);
+  kv_queue.push_back(txc);
+  kv_cond.SignalOne();
   return 0;
 }
 
index 98eef602d567ab64126b7bff8db3da28285dff4c..f2ba13745053a88115b48d28be55e353f56f8b2d 100644 (file)
@@ -168,6 +168,7 @@ public:
       STATE_KV_DONE,
       STATE_WAL_QUEUED,
       STATE_WAL_APPLYING,
+      STATE_WAL_CLEANUP,   // remove wal kv record
       STATE_WAL_DONE,
       STATE_FINISHING,
       STATE_DONE,
@@ -186,6 +187,7 @@ public:
       case STATE_KV_DONE: return "kv_done";
       case STATE_WAL_QUEUED: return "wal_queued";
       case STATE_WAL_APPLYING: return "wal_applying";
+      case STATE_WAL_CLEANUP: return "wal_cleanup";
       case STATE_WAL_DONE: return "wal_done";
       case STATE_FINISHING: return "finishing";
       case STATE_DONE: return "done";