[block-cache] tidy hit/miss tracking

This commit is contained in:
Joe Thornber 2017-08-14 13:58:12 +01:00
parent 0a47ad5a85
commit da3f9ca476
2 changed files with 11 additions and 11 deletions

View File

@ -229,7 +229,7 @@ block_cache::link_block(block &b)
}
void
block_cache::hit(block &b)
block_cache::relink(block &b)
{
unlink_block(b);
link_block(b);
@ -453,16 +453,18 @@ block_cache::zero_block(block &b)
}
void
block_cache::inc_hit_counter(unsigned flags)
block_cache::hit(block &b, unsigned flags)
{
if (flags & (GF_ZERO | GF_DIRTY))
write_hits_++;
else
read_hits_++;
relink(b);
}
void
block_cache::inc_miss_counter(unsigned flags)
block_cache::miss(unsigned flags)
{
if (flags & (GF_ZERO | GF_DIRTY))
write_misses_++;
@ -488,13 +490,11 @@ block_cache::lookup_or_read_block(block_address index, unsigned flags,
throw std::runtime_error(out.str());
}
// FIXME: confusing names, hit, then explicit inc of hit/miss counter.
hit(*b);
if (b->test_flags(BF_IO_PENDING)) {
inc_miss_counter(flags);
miss(flags);
wait_specific(*b);
} else
inc_hit_counter(flags);
hit(*b, flags);
unlink_block(*b);
@ -511,7 +511,7 @@ block_cache::lookup_or_read_block(block_address index, unsigned flags,
b->v_ = v;
} else {
inc_miss_counter(flags);
miss(flags);
b = new_block(index);
if (b) {

View File

@ -223,7 +223,7 @@ namespace bcache {
void wait_io();
void unlink_block(block &b);
void link_block(block &b);
void hit(block &b);
void relink(block &b);
void wait_all();
void wait_specific(block &b);
unsigned writeback(unsigned count);
@ -242,8 +242,8 @@ namespace bcache {
void release(block_cache::block &block);
void check_index(block_address index) const;
void inc_hit_counter(unsigned flags);
void inc_miss_counter(unsigned flags);
void hit(block &b, unsigned flags);
void miss(unsigned flags);
//--------------------------------