From 1f0eb5990f7552c744105ec7602914ffafe0007c Mon Sep 17 00:00:00 2001 From: sageweil Date: Sat, 11 Aug 2007 21:00:02 +0000 Subject: [PATCH] fixed a few objectcacher bugs git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1621 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/osdc/ObjectCacher.cc | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/branches/sage/mds/osdc/ObjectCacher.cc b/branches/sage/mds/osdc/ObjectCacher.cc index 592c8116b5b32..31d4e024cb2ed 100644 --- a/branches/sage/mds/osdc/ObjectCacher.cc +++ b/branches/sage/mds/osdc/ObjectCacher.cc @@ -394,7 +394,14 @@ void ObjectCacher::bh_read_finish(object_t oid, off_t start, size_t length, buff dout(7) << "bh_read_finish " << oid << " " << start << "~" << length + << " (bl is " << bl.length() << ")" << endl; + + if (bl.length() < length) { + bufferptr bp(length - bl.length()); + dout(7) << "bh_read_finish padding with " << bp.length() << " bytes of zeroes" << endl; + bl.push_back(bp); + } if (objects.count(oid) == 0) { dout(7) << "bh_read_finish no object cache" << endl; @@ -870,24 +877,25 @@ int ObjectCacher::writex(Objecter::OSDWrite *wr, inodeno_t ino) touch_bh(bh); bh->last_write = now; - // recombine with left? + // combine with left? map::iterator p = o->data.find(bh->start()); + assert(p->second == bh); if (p != o->data.begin()) { - assert(p->second == bh); p--; - if (p->second->is_dirty()) { + if (p->second->is_dirty() && + p->second->end() == bh->start()) { o->merge_left(p->second, bh); bh = p->second; - } + } else + p++; } - // right? - while (1) { - p = o->data.find(bh->start()); - assert(p->second == bh); - p++; - if (p == o->data.end() || !p->second->is_dirty()) break; + // combine to the right? + assert(p->second == bh); + p++; + if (p != o->data.end() && + !p->second->is_dirty() && + p->second->start() > bh->end()) o->merge_left(bh, p->second); - } } delete wr; -- 2.39.5