buf->lba = lba;
buf->data = data;
+ buf->bc = bc;
return buf;
}
ext4_dbg(DEBUG_BCACHE, DBG_WARN "Buffer is still referenced. "
"lba: %" PRIu64 ", refctr: %" PRIu32 "\n",
buf->lba, buf->refctr);
- }
+ } else
+ RB_REMOVE(ext4_buf_lru, &bc->lru_root, buf);
RB_REMOVE(ext4_buf_lba, &bc->lba_root, buf);
- RB_REMOVE(ext4_buf_lru, &bc->lru_root, buf);
/*Forcibly drop dirty buffer.*/
if (ext4_bcache_test_flag(buf, BC_DIRTY))
if (ext4_bcache_test_flag(buf, BC_DIRTY))
ext4_bcache_remove_dirty_node(bc, buf);
+ buf->end_write = NULL;
+ buf->end_write_arg = NULL;
ext4_bcache_clear_dirty(buf);
}
}
ext4_bcache_inc_ref(buf);
+ b->lb_id = lba;
b->buf = buf;
b->data = buf->data;
}
/* One more buffer in bcache now. :-) */
bc->ref_blocks++;
+ /*Calc ref blocks max depth*/
+ if (bc->max_ref_blocks < bc->ref_blocks)
+ bc->max_ref_blocks = bc->ref_blocks;
+
+
ext4_bcache_inc_ref(buf);
/* Assign new value to LRU id and increment LRU counter
* by 1*/
if (ext4_bcache_test_flag(buf, BC_DIRTY) &&
ext4_bcache_test_flag(buf, BC_UPTODATE)) {
if (bc->bdev->cache_write_back &&
- !ext4_bcache_test_flag(buf, BC_FLUSH))
+ !ext4_bcache_test_flag(buf, BC_FLUSH) &&
+ !ext4_bcache_test_flag(buf, BC_TMP))
ext4_bcache_insert_dirty_node(bc, buf);
else {
ext4_block_flush_buf(bc->bdev, buf);
}
/* The buffer is invalidated...drop it. */
- if (!ext4_bcache_test_flag(buf, BC_UPTODATE))
+ if (!ext4_bcache_test_flag(buf, BC_UPTODATE) ||
+ ext4_bcache_test_flag(buf, BC_TMP))
ext4_bcache_drop_buf(bc, buf);
}