From 157bf90e1f570e5b2d6b6bc7100b94d8cd8ba55f Mon Sep 17 00:00:00 2001 From: sage Date: Wed, 29 Jun 2005 06:36:41 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@363 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/Makefile | 8 ++--- ceph/client/Buffercache.h | 1 + ceph/client/Client.cc | 6 ++-- ceph/client/Client.h | 4 +-- ceph/include/bufferlist.h | 67 +++++++++++++++++++++++++++------------ 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/ceph/Makefile b/ceph/Makefile index f0e5ac19f0096..c70143f40c36e 100644 --- a/ceph/Makefile +++ b/ceph/Makefile @@ -1,5 +1,5 @@ -# mpicxx must be on your path; on Szilard, this means that +# mpicxx must be on your path; on Szilard and googoo, this means that # /usr/local/mpich2-1.0.2/bin must be on your path. # For now, use g++ most of the time. @@ -8,10 +8,10 @@ # This makes it less annoying to build on non-mpi hosts for dev work, and seems to # behave just fine... change ${CC} back to mpicxx if you get paranoid. CC = g++ -CFLAGS = -pg -g -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE +CFLAGS = -g -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE LIBS = -lpthread -lrt -#for normal machines +#for normal mpich2 machines MPICC = mpicxx MPICFLAGS = ${CFLAGS} MPILIBS = ${LIBS} @@ -102,7 +102,7 @@ obfstest: tcpsyn.cc mds/allmds.o client/Client.o client/SyntheticClient.o osd/OS ${MPICC} -DUSE_OBFS ${MPICFLAGS} ${MPILIBS} $^ -o $@ ../uofs/uofs.a fakesyn: fakesyn.cc mds/allmds.o client/Client.o client/SyntheticClient.o osd/OSD.o msg/FakeMessenger.o ${COMMON_OBJS} - ${CC} ${CFLAGS} ${LIBS} $^ -o $@ + ${CC} -pg ${CFLAGS} ${LIBS} $^ -o $@ fakefuse: fakefuse.cc mds/allmds.o client/Client.o osd/OSD.o client/fuse.o msg/FakeMessenger.cc ${COMMON_OBJS} ${CC} -pg ${CFLAGS} ${LIBS} -lfuse $^ -o $@ diff --git a/ceph/client/Buffercache.h b/ceph/client/Buffercache.h index 5490b76dde797..4dfd9f33679ea 100644 --- a/ceph/client/Buffercache.h +++ b/ceph/client/Buffercache.h @@ -16,6 +16,7 @@ class Buffercache; class Bufferhead : public LRUObject { + // reference counting int ref; int get() { diff --git a/ceph/client/Client.cc b/ceph/client/Client.cc index e371b6a3a0155..0b3693fceadf0 100644 --- a/ceph/client/Client.cc +++ b/ceph/client/Client.cc @@ -65,11 +65,11 @@ Client::~Client() void Client::tear_down_cache() { // fh's - for (map::iterator it = fh_map.begin(); + for (hash_map::iterator it = fh_map.begin(); it != fh_map.end(); it++) { Fh *fh = it->second; - dout(3) << "forcing close of fh " << it->first << " ino " << fh->inode->inode.ino << endl; + dout(1) << "tear_down_cache forcing close of fh " << it->first << " ino " << fh->inode->inode.ino << endl; put_inode(fh->inode); delete fh; } @@ -121,7 +121,7 @@ void Client::dump_cache() if (root) dump_inode(root, did); - for (map::iterator it = inode_map.begin(); + for (hash_map::iterator it = inode_map.begin(); it != inode_map.end(); it++) { if (did.count(it->second)) continue; diff --git a/ceph/client/Client.h b/ceph/client/Client.h index 47f0e970c815e..5c1800bd02371 100644 --- a/ceph/client/Client.h +++ b/ceph/client/Client.h @@ -149,12 +149,12 @@ class Client : public Dispatcher { Filer *filer; // (non-blocking) osd interface // cache - map inode_map; + hash_map inode_map; Inode* root; LRU lru; // lru list of Dentry's in our local metadata cache. // file handles - map fh_map; + hash_map fh_map; // global (client) lock Mutex client_lock; diff --git a/ceph/include/bufferlist.h b/ceph/include/bufferlist.h index 5035c5eb30bec..93e6c068af409 100644 --- a/ceph/include/bufferlist.h +++ b/ceph/include/bufferlist.h @@ -20,16 +20,21 @@ using namespace __gnu_cxx; class bufferlist { private: + /* local state limited to _buffers, and _len. + * we maintain _len ourselves, so we must be careful when fiddling with buffers! + */ list _buffers; + int _len; public: // cons/des - bufferlist() { + bufferlist() : _len(0) { bdbout(1) << "bufferlist.cons " << this << endl; } - bufferlist(bufferlist& bl) { + bufferlist(bufferlist& bl) : _len(0) { bdbout(1) << "bufferlist.cons " << this << endl; _buffers = bl._buffers; + _len = bl._len; } ~bufferlist() { bdbout(1) << "bufferlist.des " << this << endl; @@ -40,17 +45,6 @@ class bufferlist { } */ - // sort-of-like-assignment-op - void claim(bufferlist& bl) { - // free my buffers - _buffers.clear(); - claim_append(bl); - } - void claim_append(bufferlist& bl) { - // steal the other guy's buffers - _buffers.splice( _buffers.end(), bl._buffers ); - } - // accessors list& buffers() { return _buffers; @@ -59,13 +53,18 @@ class bufferlist { //list::iterator end() { return _buffers.end(); } int length() { - int len = 0; - for (list::iterator it = _buffers.begin(); - it != _buffers.end(); - it++) { - len += (*it).length(); +#if 0 + { // DEBUG: verify _len + int len = 0; + for (list::iterator it = _buffers.begin(); + it != _buffers.end(); + it++) { + len += (*it).length(); + } + assert(len == _len); } - return len; +#endif + return _len; } void _rope(crope& r) { @@ -78,22 +77,44 @@ class bufferlist { // modifiers void clear() { _buffers.clear(); + _len = 0; } void push_front(bufferptr& bp) { _buffers.push_front(bp); + _len += bp.length(); } void push_front(buffer *b) { bufferptr bp(b); _buffers.push_front(bp); + _len += bp.length(); } void push_back(bufferptr& bp) { _buffers.push_back(bp); + _len += bp.length(); } void push_back(buffer *b) { bufferptr bp(b); + _buffers.push_back(bp); + _len += bp.length(); + + } + + // sort-of-like-assignment-op + void claim(bufferlist& bl) { + // free my buffers + clear(); + claim_append(bl); + } + void claim_append(bufferlist& bl) { + // steal the other guy's buffers + _len += bl._len; + _buffers.splice( _buffers.end(), bl._buffers ); + bl._len = 0; } + + // crope lookalikes void copy(int off, int len, char *dest) { @@ -193,6 +214,7 @@ class bufferlist { memcpy(_buffers.back().c_str() + blen, data, avail); blen += avail; _buffers.back().set_length(blen); + _len += avail; data += avail; len -= avail; } @@ -246,7 +268,7 @@ class bufferlist { void substr_of(bufferlist& other, int off, int len) { - _buffers.clear(); + clear(); // skip off list::iterator curbuf = other._buffers.begin(); @@ -269,6 +291,7 @@ class bufferlist { if (off + len < (*curbuf).length()) { //cout << "copying partial of " << *curbuf << endl; _buffers.push_back( bufferptr( *curbuf, len, off ) ); + _len += len; break; } @@ -276,6 +299,7 @@ class bufferlist { //cout << "copying end (all?) of " << *curbuf << endl; int howmuch = (*curbuf).length() - off; _buffers.push_back( bufferptr( *curbuf, howmuch, off ) ); + _len += howmuch; len -= howmuch; off = 0; curbuf++; @@ -305,6 +329,7 @@ class bufferlist { // insert it before curbuf (which we'll hose) //cout << "keeping front " << off << " of " << *curbuf << endl; _buffers.insert( curbuf, bufferptr( *curbuf, off, 0 ) ); + _len += off; } while (len > 0) { @@ -315,6 +340,7 @@ class bufferlist { claim_by->append( *curbuf, len, off ); (*curbuf).set_offset( off + len + (*curbuf).offset() ); // ignore beginning big (*curbuf).set_length( (*curbuf).length() - len - off ); + _len -= off+len; //cout << " now " << *curbuf << endl; break; } @@ -324,6 +350,7 @@ class bufferlist { //cout << "discarding " << howmuch << " of " << *curbuf << endl; if (claim_by) claim_by->append( *curbuf, howmuch, off ); + _len -= (*curbuf).length(); _buffers.erase( curbuf++ ); len -= howmuch; off = 0; -- 2.47.3