]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fixed pesky read objectcacher bug
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 11 Aug 2007 23:14:47 +0000 (23:14 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 11 Aug 2007 23:14:47 +0000 (23:14 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1624 29311d96-e01e-0410-9327-a35deaab8ce9

branches/sage/mds/osdc/ObjectCacher.cc
branches/sage/mds/osdc/ObjectCacher.h

index 31d4e024cb2edcd8e1000dc6647cb9a1869bc13c..7f5bc439c6bca5ecc24d727d0a8f7328dfe09833 100644 (file)
@@ -255,11 +255,6 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr
         BufferHead *bh = p->second;
         dout(10) << "map_write bh " << *bh << " intersected" << endl;
         
-        /*if (bh->is_dirty()) {
-          // already dirty, let's use it.
-          final = bh;
-        } else {
-        */
         if (p->first < cur) {
           assert(final == 0);
           if (cur + max >= p->first + p->second->length()) {
@@ -275,10 +270,6 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr
             split(final, cur+max);
           }
         } else if (p->first == cur) {
-          /*if (bh->is_dirty()) {
-              // already dirty, use it.
-            } 
-            else*/
           if (p->second->length() <= max) {
             // whole bufferhead, piece of cake.
           } else {
@@ -286,7 +277,7 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr
             split(bh, cur + max);        // just split
           }
           if (final) 
-            merge_left(final,bh);
+            merge_left(final, bh);
           else
             final = bh;
         }
@@ -399,7 +390,9 @@ void ObjectCacher::bh_read_finish(object_t oid, off_t start, size_t length, buff
 
   if (bl.length() < length) {
     bufferptr bp(length - bl.length());
-    dout(7) << "bh_read_finish padding with " << bp.length() << " bytes of zeroes" << endl;
+    bp.zero();
+    dout(7) << "bh_read_finish " << oid << " padding " << start << "~" << length 
+           << " with " << bp.length() << " bytes of zeroes" << endl;
     bl.push_back(bp);
   }
   
@@ -750,9 +743,9 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
       for (map<off_t, BufferHead*>::iterator bh_it = hits.begin();
            bh_it != hits.end();
            bh_it++) {
-               dout(10) << "readx hit bh " << *bh_it->second << endl;
+       dout(10) << "readx hit bh " << *bh_it->second << endl;
         hit_ls.push_back(bh_it->second);
-         }
+      }
 
       // create reverse map of buffer offset -> object for the eventual result.
       // this is over a single ObjectExtent, so we know that
@@ -760,7 +753,7 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
       //  - the buffer frags need not be (and almost certainly aren't)
       off_t opos = ex_it->start;
       map<off_t, BufferHead*>::iterator bh_it = hits.begin();
-         assert(bh_it->second->start() <= opos);
+      assert(bh_it->second->start() <= opos);
       size_t bhoff = opos - bh_it->second->start();
       map<size_t,size_t>::iterator f_it = ex_it->buffer_extents.begin();
       size_t foff = 0;
@@ -775,9 +768,13 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
 
         size_t len = MIN(f_it->second - foff,
                          bh->length() - bhoff);
-        stripe_map[f_it->first].substr_of(bh->bl,
-                                          opos - bh->start(),
-                                          len);
+       bufferlist bit;  // put substr here first, since substr_of clobbers, and
+                        // we may get multiple bh's at this stripe_map position
+       bit.substr_of(bh->bl,
+                     opos - bh->start(),
+                     len);
+        stripe_map[f_it->first].claim_append(bit);
+
         opos += len;
         bhoff += len;
         foff += len;
@@ -819,6 +816,7 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
     dout(10) << "readx  adding buffer len " << i->second.length() << " at " << pos << endl;
     pos += i->second.length();
     rd->bl->claim_append(i->second);
+    assert(rd->bl->length() == pos);
   }
   dout(10) << "readx  result is " << rd->bl->length() << endl;
 
index 15109ab782167b610c40bf6ec26a5dd8e3b3f300..054953e4670cc41481462cf6d680aaa56a23af06 100644 (file)
@@ -100,8 +100,8 @@ class ObjectCacher {
     ObjectCacher *oc;
     object_t  oid;   // this _always_ is oid.rev=0
     inodeno_t ino;
-       objectrev_t rev; // last rev we're written
-       ObjectLayout layout;
+    objectrev_t rev; // last rev we're written
+    ObjectLayout layout;
     
   public:
     map<off_t, BufferHead*>     data;
@@ -538,6 +538,7 @@ inline ostream& operator<<(ostream& out, ObjectCacher::BufferHead &bh)
   if (bh.is_dirty()) out << " dirty";
   if (bh.is_clean()) out << " clean";
   if (bh.is_missing()) out << " missing";
+  if (bh.bl.length() > 0) out << " firstbyte=" << (int)bh.bl[0];
   out << "]";
   return out;
 }