]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/ObjectCacher: add ZERO bufferheads from map_read()
authorSage Weil <sage@inktank.com>
Fri, 26 Oct 2012 18:54:50 +0000 (11:54 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Oct 2012 18:56:05 +0000 (11:56 -0700)
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>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index f8efb5a3f4f33526ea565a24927ac096701bf36c..a05d75e015660a3512de7c499ed2e19ded3a7423 100644 (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 {
index baeb77f2d62765d779a1fc057d1038a9768c25ca..331b69c175827e97b8dde689c340a450c3221c5e 100644 (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;