assert(bh_lru_rest.lru_get_size() == 0);
assert(bh_lru_dirty.lru_get_size() == 0);
assert(ob_lru.lru_get_size() == 0);
- assert(dirty_bh.empty());
+ assert(dirty_or_tx_bh.empty());
}
void ObjectCacher::perf_start()
set<Object*> waitfor_commit;
set<BufferHead*>::iterator next, it;
- next = it = dirty_bh.begin();
- while (it != dirty_bh.end()) {
+ next = it = dirty_or_tx_bh.begin();
+ while (it != dirty_or_tx_bh.end()) {
next++;
BufferHead *bh = *it;
waitfor_commit.insert(bh->ob);
if (s == BufferHead::STATE_DIRTY && bh->get_state() != BufferHead::STATE_DIRTY) {
bh_lru_rest.lru_remove(bh);
bh_lru_dirty.lru_insert_top(bh);
- dirty_bh.insert(bh);
- }
- if (s != BufferHead::STATE_DIRTY && bh->get_state() == BufferHead::STATE_DIRTY) {
+ dirty_or_tx_bh.insert(bh);
+ } else if (s != BufferHead::STATE_DIRTY && bh->get_state() == BufferHead::STATE_DIRTY) {
bh_lru_dirty.lru_remove(bh);
bh_lru_rest.lru_insert_top(bh);
- dirty_bh.erase(bh);
- }
- if (s != BufferHead::STATE_ERROR && bh->get_state() == BufferHead::STATE_ERROR) {
+ dirty_or_tx_bh.erase(bh);
+ } else if (s == BufferHead::STATE_TX && bh->get_state() != BufferHead::STATE_TX) {
+ dirty_or_tx_bh.insert(bh);
+ } else if (s != BufferHead::STATE_TX && bh->get_state() == BufferHead::STATE_TX) {
+ dirty_or_tx_bh.erase(bh);
+ } else if (s != BufferHead::STATE_ERROR && bh->get_state() == BufferHead::STATE_ERROR) {
bh->error = 0;
}
ob->add_bh(bh);
if (bh->is_dirty()) {
bh_lru_dirty.lru_insert_top(bh);
- dirty_bh.insert(bh);
+ dirty_or_tx_bh.insert(bh);
+ } else if (bh->is_tx()) {
+ dirty_or_tx_bh.insert(bh);
} else {
bh_lru_rest.lru_insert_top(bh);
}
ob->remove_bh(bh);
if (bh->is_dirty()) {
bh_lru_dirty.lru_remove(bh);
- dirty_bh.erase(bh);
+ dirty_or_tx_bh.erase(bh);
+ } else if (bh->is_tx()) {
+ dirty_or_tx_bh.insert(bh);
} else {
bh_lru_rest.lru_remove(bh);
}