diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index 7e26d20d5f6..5253755d3cb 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -197,8 +197,8 @@ int ObjectCacher::Object::map_read(OSDRead *rd, if (p == data.end()) { // rest is a miss. BufferHead *n = new BufferHead(this); - n->set_start( cur ); - n->set_length( left ); + n->set_start(cur); + n->set_length(left); oc->bh_add(this, n); missing[cur] = n; dout(20) << "map_read miss " << left << " left, " << *n << dendl; @@ -303,14 +303,16 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr) oc->bh_add(this, final); dout(10) << "map_write adding trailing bh " << *final << dendl; } else { - final->set_length( final->length() + max ); + oc->bh_stat_sub(final); + final->set_length(final->length() + max); + oc->bh_stat_add(final); } left -= max; cur += max; continue; } - dout(10) << "p is " << *p->second << dendl; + dout(10) << "cur is " << cur << ", p is " << *p->second << dendl; if (p->first <= cur) { BufferHead *bh = p->second; @@ -359,7 +361,9 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr) loff_t glen = MIN(next - cur, max); dout(10) << "map_write gap " << cur << "~" << glen << dendl; if (final) { - final->set_length( final->length() + glen ); + oc->bh_stat_sub(final); + final->set_length(final->length() + glen); + oc->bh_stat_add(final); } else { final = new BufferHead(this); final->set_start( cur ); diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index fd90e2d4111..79fbdff0a7f 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -90,12 +90,12 @@ class ObjectCacher { last_write_tid(0) {} // extent - loff_t start() { return ex.start; } + loff_t start() const { return ex.start; } void set_start(loff_t s) { ex.start = s; } - loff_t length() { return ex.length; } + loff_t length() const { return ex.length; } void set_length(loff_t l) { ex.length = l; } - loff_t end() { return ex.start + ex.length; } - loff_t last() { return end() - 1; } + loff_t end() const { return ex.start + ex.length; } + loff_t last() const { return end() - 1; } // states void set_state(int s) { @@ -103,7 +103,7 @@ class ObjectCacher { if (state == STATE_RX || state == STATE_TX) put(); state = s; } - int get_state() { return state; } + int get_state() const { return state; } bool is_missing() { return state == STATE_MISSING; } bool is_dirty() { return state == STATE_DIRTY; } @@ -321,6 +321,8 @@ class ObjectCacher { loff_t stat_tx; loff_t stat_missing; + void verify_stats() const; + void bh_stat_add(BufferHead *bh) { switch (bh->get_state()) { case BufferHead::STATE_MISSING: