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

View File

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