From fcf95d2568b23cab2294b540a7198ce075829347 Mon Sep 17 00:00:00 2001 From: sage Date: Fri, 15 Sep 2006 23:49:45 +0000 Subject: [PATCH] simplify realloc; still testing git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@862 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/ebofs/BlockDevice.cc | 2 ++ ceph/ebofs/Ebofs.cc | 59 +++++++++++---------------------------- ceph/ebofs/nodes.h | 2 +- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/ceph/ebofs/BlockDevice.cc b/ceph/ebofs/BlockDevice.cc index aa3f0a7817d1f..2e72fa63dbf2d 100644 --- a/ceph/ebofs/BlockDevice.cc +++ b/ceph/ebofs/BlockDevice.cc @@ -463,6 +463,7 @@ int BlockDevice::_cancel_io(biovec *bio) int BlockDevice::count_io(block_t start, block_t len) { + lock.Lock(); int n = 0; multimap::iterator p = io_queue.lower_bound(start); while (p != io_queue.end() && p->first < start+len) { @@ -470,6 +471,7 @@ int BlockDevice::count_io(block_t start, block_t len) n++; p++; } + lock.Unlock(); return n; } diff --git a/ceph/ebofs/Ebofs.cc b/ceph/ebofs/Ebofs.cc index 249129266a29f..086101936f95a 100644 --- a/ceph/ebofs/Ebofs.cc +++ b/ceph/ebofs/Ebofs.cc @@ -1294,11 +1294,10 @@ void Ebofs::alloc_write(Onode *on, } } - // reallocate uncommitted but cancelable stuff too? - list re_tx; + // reallocate uncommitted too? if (1) { list tx; - + ObjectCache *oc = on->get_oc(&bc); oc->find_tx(start, len, tx); @@ -1307,31 +1306,27 @@ void Ebofs::alloc_write(Onode *on, p++) { BufferHead *bh = *p; - // let's just do single bh's for now! - if (bh->length() > 1) continue; - // cancelable/moveable? if (alloc.contains(bh->start(), bh->length())) { dout(10) << "alloc_write " << *bh << " already in " << alloc << endl; + continue; + } + + vector old; + on->map_extents(bh->start(), bh->length(), old); + assert(old.size() == 1); + + if (bc.bh_cancel_write(bh)) { + dout(10) << "alloc_write unallocated " << old[0] << ", canceled " << *bh << endl; + allocator.unallocate(old[0]); // release (into free) } else { - if (bc.bh_cancel_write(bh)) { - re_tx.push_back(bh); - alloc.insert(bh->start(), bh->length()); - - // release (into free) - vector old; - on->map_extents(bh->start(), bh->length(), old); - assert(old.size() == 1); - allocator.unallocate(old[0]); - - dout(10) << "alloc_write canceled " << *bh << ", unalloc " << old[0] << endl; - } else { - dout(10) << "alloc_write couldn't cancel " << *bh << endl; - } + dout(10) << "alloc_write released " << old[0] << ", couldn't canceled " << *bh << endl; + allocator.release(old[0]); // release (into limbo) } - break; // only do tailing bh for now. + + alloc.insert(bh->start(), bh->length()); } - + dout(10) << "alloc_write will (re)alloc " << alloc << " on " << *on << endl; } @@ -1378,26 +1373,6 @@ void Ebofs::alloc_write(Onode *on, cur += ex.length; } } - - - // re-tx anything we reallocated? - /* - for (list::iterator p = re_tx.begin(); - p != re_tx.end(); - p++) { - BufferHead *bh = *p; - dout(10) << "alloc_write re-tx reallocated " << *bh << endl; - - // split bh if necessary! (our new alloc may not lay on the right boundaries) - vector ex; - on->map_extents(bh->start(), bh->length(), ex); - if (ex.size() > 1) { - dout(10) << "alloc_write splitting reallocated -- not implemented " << *bh << endl; - assert(0); - } - - bc.bh_write(on,bh); - }*/ } diff --git a/ceph/ebofs/nodes.h b/ceph/ebofs/nodes.h index fddb4c65c78e9..a580fde588eae 100644 --- a/ceph/ebofs/nodes.h +++ b/ceph/ebofs/nodes.h @@ -409,7 +409,7 @@ class NodePool { dout(20) << "ebofs.nodepool.commit_start start" << endl; assert(flushing == 0); - if (1) + if (0) for (unsigned i=0; i