assert(out_on_commit);
assert(out_on_applied_sync);
list<Context *> on_applied, on_commit, on_applied_sync;
- for (vector<Transaction>::iterator i = t.begin();
- i != t.end();
- ++i) {
- on_applied.splice(on_applied.end(), (*i).on_applied);
- on_commit.splice(on_commit.end(), (*i).on_commit);
- on_applied_sync.splice(on_applied_sync.end(), (*i).on_applied_sync);
+ for (auto& i : t) {
+ on_applied.splice(on_applied.end(), i.on_applied);
+ on_commit.splice(on_commit.end(), i.on_commit);
+ on_applied_sync.splice(on_applied_sync.end(), i.on_applied_sync);
}
*out_on_applied = C_Contexts::list_to_context(on_applied);
*out_on_commit = C_Contexts::list_to_context(on_commit);
*out_on_applied_sync = C_Contexts::list_to_context(on_applied_sync);
}
+ static void collect_contexts(
+ vector<Transaction>& t,
+ list<Context*> *out_on_applied,
+ list<Context*> *out_on_commit,
+ list<Context*> *out_on_applied_sync) {
+ assert(out_on_applied);
+ assert(out_on_commit);
+ assert(out_on_applied_sync);
+ for (auto& i : t) {
+ out_on_applied->splice(out_on_applied->end(), i.on_applied);
+ out_on_commit->splice(out_on_commit->end(), i.on_commit);
+ out_on_applied_sync->splice(out_on_applied_sync->end(),
+ i.on_applied_sync);
+ }
+ }
Context *get_on_applied() {
return C_Contexts::list_to_context(on_applied);
void BlueStore::_txc_committed_kv(TransContext *txc)
{
dout(20) << __func__ << " txc " << txc << dendl;
-
unsigned n = txc->osr->parent->shard_hint.hash_to_shard(m_finisher_num);
- if (txc->oncommit) {
- logger->tinc(l_bluestore_commit_lat, ceph_clock_now() - txc->start);
- finishers[n]->queue(txc->oncommit);
- txc->oncommit = NULL;
- }
-
- if (!txc->oncommits.empty()) {
- finishers[n]->queue(txc->oncommits);
- }
+ logger->tinc(l_bluestore_commit_lat, ceph_clock_now() - txc->start);
+ finishers[n]->queue(txc->oncommits);
}
void BlueStore::_txc_finish(TransContext *txc)
ThreadPool::TPHandle *handle)
{
FUNCTRACE(cct);
- Context *onreadable;
- Context *ondisk;
- Context *onreadable_sync;
+ list<Context *> on_applied, on_commit, on_applied_sync;
ObjectStore::Transaction::collect_contexts(
- tls, &onreadable, &ondisk, &onreadable_sync);
+ tls, &on_applied, &on_commit, &on_applied_sync);
if (cct->_conf->objectstore_blackhole) {
dout(0) << __func__ << " objectstore_blackhole = TRUE, dropping transaction"
<< dendl;
- delete ondisk;
- delete onreadable;
- delete onreadable_sync;
+ for (auto& l : { on_applied, on_commit, on_applied_sync }) {
+ for (auto c : l) {
+ delete c;
+ }
+ }
return 0;
}
utime_t start = ceph_clock_now();
// prepare
TransContext *txc = _txc_create(osr);
- txc->oncommit = ondisk;
+ txc->oncommits.swap(on_commit);
for (vector<Transaction>::iterator p = tls.begin(); p != tls.end(); ++p) {
(*p).set_osr(osr);
_txc_state_proc(txc);
// we're immediately readable (unlike FileStore)
- if (onreadable_sync) {
- onreadable_sync->complete(0);
+ for (auto c : on_applied_sync) {
+ c->complete(0);
}
- if (onreadable) {
+ unsigned n = osr->parent->shard_hint.hash_to_shard(m_finisher_num);
+ for (auto c : on_applied) {
// NOTE: these may complete out of order since some may be sync and some
// may be async.
- if (!onreadable->sync_complete(0)) {
- unsigned n = osr->parent->shard_hint.hash_to_shard(m_finisher_num);
- finishers[n]->queue(onreadable);
+ if (!c->sync_complete(0)) {
+ finishers[n]->queue(c);
}
}