From c25cb2973a7dc06b0fffc4563cbcfe6d94494842 Mon Sep 17 00:00:00 2001 From: carlosm Date: Tue, 12 Jul 2005 22:24:53 +0000 Subject: [PATCH] Modified Files: client/Buffercache.cc client/Client.cc Fixed bug in map_existing that listed unnecessary holes git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@455 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/client/Buffercache.cc | 17 ++++++++--------- ceph/client/Client.cc | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ceph/client/Buffercache.cc b/ceph/client/Buffercache.cc index f9ff6906a33..21f0c51696a 100644 --- a/ceph/client/Buffercache.cc +++ b/ceph/client/Buffercache.cc @@ -29,6 +29,7 @@ Bufferhead::~Bufferhead() assert(lru_is_expireable()); assert(read_waiters.empty()); assert(write_waiters.empty()); + assert(!fc->buffer_map.count(offset)); bc->lru.lru_remove(this); // debug segmentation fault if (bl.buffers().empty()) { @@ -271,9 +272,9 @@ Filecache::map_existing(size_t len, } need_off = actual_off + bh->bl.length(); } - if (need_off < actual_off + len) { - holes[need_off] = (size_t) (actual_off + len - need_off); - dout(10) << "bc: map: hole " << need_off << " " << holes[need_off] << endl; + if (need_off < start_off + len) { + holes[need_off] = (size_t) (start_off + len - need_off); + dout(10) << "bc: map: last hole " << need_off << " " << holes[need_off] << endl; } return rvalue; } @@ -441,17 +442,15 @@ void Buffercache::release_file(inodeno_t ino) dout(7) << "bc: release_file ino: " << ino << endl; assert(bcache_map.count(ino)); Filecache *fc = bcache_map[ino]; - for (map::iterator it = fc->buffer_map.begin(); - it != fc->buffer_map.end(); + map to_release = fc->buffer_map; + fc->buffer_map.clear(); + for (map::iterator it = to_release.begin(); + it != to_release.end(); it++) { - decrease_size(it->second->bl.length()); - dout(6) << "bc: release_file: clean_size: " << get_clean_size() << " dirty_size: " << get_dirty_size() << " rx_size: " << get_rx_size() << " tx_size: " << get_tx_size() << " age: " << dirty_buffers.get_age() << endl; - assert(clean_size >= 0); delete it->second; } - fc->buffer_map.clear(); bcache_map.erase(ino); delete fc; } diff --git a/ceph/client/Client.cc b/ceph/client/Client.cc index 02c46492694..8e115f31807 100644 --- a/ceph/client/Client.cc +++ b/ceph/client/Client.cc @@ -1371,6 +1371,7 @@ int Client::read(fileh_t fh, char *buf, size_t size, off_t offset) assert(rvalue > 0); dout(7) << "read bc hit: immediately returning " << rvalue << " bytes" << endl; } + assert(!(rvalue == size) || holes.empty()); // issue reads for holes int hole_rvalue = 0; //FIXME: don't really need to track rvalue in MissFinish context for (hole = holes.begin(); hole != holes.end(); hole++) {