]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/ObjectCacher: fill in zero buffers in map_read() on miss if complete
authorSage Weil <sage@inktank.com>
Wed, 24 Oct 2012 21:42:50 +0000 (14:42 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Oct 2012 18:31:45 +0000 (11:31 -0700)
If we know we have the complete object in cache, fill in zero buffers
when we miss.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osdc/ObjectCacher.cc

index f2f11187c2c9765c61929312bb21121fbc862fdd..cf37edd7b7fb252cb70f7450f0b7d69a8b4fc737 100644 (file)
@@ -172,8 +172,9 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
        ex_it != rd->extents.end();
        ex_it++) {
     
-    if (ex_it->oid != oid.oid) continue;
-    
+    if (ex_it->oid != oid.oid)
+      continue;
+
     ldout(oc->cct, 10) << "map_read " << ex_it->oid 
                       << " " << ex_it->offset << "~" << ex_it->length
                       << dendl;
@@ -190,8 +191,17 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
         n->set_start(cur);
         n->set_length(left);
         oc->bh_add(this, n);
-        missing[cur] = n;
-        ldout(oc->cct, 20) << "map_read miss " << left << " left, " << *n << dendl;
+       if (complete) {
+         bufferptr bp(left);
+         bp.zero();
+         n->bl.append(bp);
+         oc->mark_clean(n);
+         hits[cur] = n;
+         ldout(oc->cct, 20) << "map_read miss+complete+zero " << left << " left, " << *n << dendl;
+       } else {
+         missing[cur] = n;
+         ldout(oc->cct, 20) << "map_read miss " << left << " left, " << *n << dendl;
+       }
         cur += left;
         left -= left;
         assert(left == 0);
@@ -228,13 +238,23 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
         // gap.. miss
         loff_t next = p->first;
         BufferHead *n = new BufferHead(this);
-        n->set_start( cur );
-        n->set_length( MIN(next - cur, left) );
+       loff_t len = MIN(next - cur, left);
+        n->set_start(cur);
+       n->set_length(len);
         oc->bh_add(this,n);
-        missing[cur] = n;
+       if (complete) {
+         bufferptr bp(len);
+         bp.zero();
+         n->bl.append(bp);
+         oc->mark_clean(n);
+         hits[cur] = n;
+         ldout(oc->cct, 20) << "map_read gap+complete+zero " << *n << dendl;
+       } else {
+         missing[cur] = n;
+         ldout(oc->cct, 20) << "map_read gap " << *n << dendl;
+       }
         cur += MIN(left, n->length());
         left -= MIN(left, n->length());
-        ldout(oc->cct, 20) << "map_read gap " << *n << dendl;
         continue;    // more?
       } else {
         assert(0);