From 1edb00ef42101a7829ab853677251dfea3f99e93 Mon Sep 17 00:00:00 2001 From: sageweil Date: Sat, 11 Aug 2007 23:14:47 +0000 Subject: [PATCH] fixed pesky read objectcacher bug git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1624 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/osdc/ObjectCacher.cc | 32 ++++++++++++-------------- branches/sage/mds/osdc/ObjectCacher.h | 5 ++-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/branches/sage/mds/osdc/ObjectCacher.cc b/branches/sage/mds/osdc/ObjectCacher.cc index 31d4e024cb2ed..7f5bc439c6bca 100644 --- a/branches/sage/mds/osdc/ObjectCacher.cc +++ b/branches/sage/mds/osdc/ObjectCacher.cc @@ -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::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::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::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; diff --git a/branches/sage/mds/osdc/ObjectCacher.h b/branches/sage/mds/osdc/ObjectCacher.h index 15109ab782167..054953e4670cc 100644 --- a/branches/sage/mds/osdc/ObjectCacher.h +++ b/branches/sage/mds/osdc/ObjectCacher.h @@ -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 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; } -- 2.39.5