From 94a84d29086f48a742ce0545c705f0e2554dd00d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 26 Oct 2012 11:54:50 -0700 Subject: [PATCH] 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 --- src/osdc/ObjectCacher.cc | 13 ++++--------- src/osdc/ObjectCacher.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index f8efb5a3f4f..a05d75e0156 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -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 { diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index baeb77f2d62..331b69c1758 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -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;