osr->flush();
}
+void BlueStore::Collection::flush_all_but_last()
+{
+ osr->flush_all_but_last();
+}
+
void BlueStore::Collection::open_shared_blob(uint64_t sbid, BlobRef b)
{
assert(!b->shared_blob);
} while (p != osr->q.end() &&
p->state == TransContext::STATE_IO_DONE);
- if (osr->kv_submitted_waiters &&
- osr->_is_all_kv_submitted()) {
+ if (osr->kv_submitted_waiters) {
osr->qcond.notify_all();
}
}
txc->state = TransContext::STATE_KV_SUBMITTED;
if (txc->osr->kv_submitted_waiters) {
std::lock_guard<std::mutex> l(txc->osr->qlock);
- if (txc->osr->_is_all_kv_submitted()) {
- txc->osr->qcond.notify_all();
- }
+ txc->osr->qcond.notify_all();
}
} else {
CollectionRef& c,
OnodeRef &o)
{
- dout(15) << __func__ << " " << c->cid << " " << o->oid << dendl;
+ dout(15) << __func__ << " " << c->cid << " " << o->oid
+ << " onode " << o.get()
+ << " txc "<< txc << dendl;
int r = _do_remove(txc, c, o);
dout(10) << __func__ << " " << c->cid << " " << o->oid << " = " << r << dendl;
return r;
dout(15) << __func__ << " " << cid << dendl;
int r;
+ (*c)->flush_all_but_last();
{
RWLock::WLocker l(coll_lock);
if (!*c) {
exists = !onode || onode->exists;
if (exists) {
dout(10) << __func__ << " " << *it
- << " exists in db" << dendl;
+ << " exists in db, "
+ << (!onode ? "not present in ram" : "present in ram")
+ << dendl;
}
}
if (!exists) {
bool flush_commit(Context *c) override;
void flush() override;
+ void flush_all_but_last();
Collection(BlueStore *ns, Cache *ca, coll_t c);
};
}
}
+ void flush_all_but_last() {
+ std::unique_lock<std::mutex> l(qlock);
+ assert (q.size() >= 1);
+ while (true) {
+ // set flag before the check because the condition
+ // may become true outside qlock, and we need to make
+ // sure those threads see waiters and signal qcond.
+ ++kv_submitted_waiters;
+ if (q.size() <= 1) {
+ --kv_submitted_waiters;
+ return;
+ } else {
+ auto it = q.rbegin();
+ it++;
+ if (it->state >= TransContext::STATE_KV_SUBMITTED) {
+ return;
+ }
+ }
+ qcond.wait(l);
+ --kv_submitted_waiters;
+ }
+ }
+
bool flush_commit(Context *c) {
std::lock_guard<std::mutex> l(qlock);
if (q.empty()) {