osdc/ObjectCacher: add ZERO bufferheads from map_read()

When we add a bufferhead with zeros to the Object data map, use the new
zero type instead of allocating actual zeros.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-10-26 11:54:50 -07:00
parent fde7fe6840
commit 94a84d2908
2 changed files with 5 additions and 10 deletions

View File

@ -192,10 +192,7 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
n->set_length(left);
oc->bh_add(this, n);
if (complete) {
bufferptr bp(left);
bp.zero();
n->bl.append(bp);
oc->mark_clean(n);
oc->mark_zero(n);
hits[cur] = n;
ldout(oc->cct, 20) << "map_read miss+complete+zero " << left << " left, " << *n << dendl;
} else {
@ -215,7 +212,8 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
if (e->is_clean() ||
e->is_dirty() ||
e->is_tx()) {
e->is_tx() ||
e->is_zero()) {
hits[cur] = e; // readable!
ldout(oc->cct, 20) << "map_read hit " << *e << dendl;
} else if (e->is_rx()) {
@ -243,10 +241,7 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
n->set_length(len);
oc->bh_add(this,n);
if (complete) {
bufferptr bp(len);
bp.zero();
n->bl.append(bp);
oc->mark_clean(n);
oc->mark_zero(n);
hits[cur] = n;
ldout(oc->cct, 20) << "map_read gap+complete+zero " << *n << dendl;
} else {

View File

@ -84,7 +84,7 @@ class ObjectCacher {
// states
static const int STATE_MISSING = 0;
static const int STATE_CLEAN = 1;
static const int STATE_ZERO = 2;
static const int STATE_ZERO = 2; // NOTE: these are *clean* zeros
static const int STATE_DIRTY = 3;
static const int STATE_RX = 4;
static const int STATE_TX = 5;