From: Sage Weil Date: Fri, 10 Apr 2015 21:28:13 +0000 (-0700) Subject: os/newstore: let wal cleanup kv txn get batched X-Git-Tag: v9.1.0~242^2~79 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86a3f7dd514f3798fc9c3e4b2839f1209b08bb58;p=ceph.git os/newstore: let wal cleanup kv txn get batched 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 --- diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index 8989e584bc71..daaee2183ac0 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -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; } diff --git a/src/os/newstore/NewStore.h b/src/os/newstore/NewStore.h index 98eef602d567..f2ba13745053 100644 --- a/src/os/newstore/NewStore.h +++ b/src/os/newstore/NewStore.h @@ -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";