*** empty log message ***

git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@514 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
sage 2005-12-03 19:54:56 +00:00
parent c50a325b36
commit 28efa364d0
10 changed files with 102 additions and 16 deletions

View File

@ -21,6 +21,11 @@ MPILIBS = ${LIBS}
#MPICFLAGS = ${CFLAGS} -I/usr/lib/mpi/include -L/usr/lib/mpi/mpi_gnu/lib
#MPILIBS = ${LIBS} -lelan -lmpi
EBOFS_OBJS= \
ebofs/BlockDevice.o\
ebofs/BufferCache.o\
ebofs/Ebofs.o\
ebofs/Allocator.o
MDS_OBJS= \
mds/MDS.o\
@ -123,6 +128,10 @@ tcpsyn: tcpsyn.cc mds/allmds.o client/Client.o client/Buffercache.o osd/OSD.o ${
obfstest: tcpsyn.cc mds/allmds.o client/Client.o client/Buffercache.o osd/OSD.cc osd/OBFSStore.o msg/TCPMessenger.cc ${COMMON_OBJS} $(SYN_OBJS)
${MPICC} -DUSE_OBFS ${MPICFLAGS} ${MPILIBS} $^ -o $@ ../uofs/uofs.a
# ebofs
mkfs.ebofs: ebofs/mkfs.ebofs.cc config.cc common/Clock.o ${EBOFS_OBJS}
${CC} -pg ${CFLAGS} ${LIBS} $^ -o $@
testmpi: test/testmpi.cc msg/MPIMessenger.cc config.o common/Timer.o common/clock.o msg/Messenger.o msg/Dispatcher.o msg/error.o

36
ceph/common/Thread.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef __THREAD_H
#define __THREAD_H
#include <pthread.h>
class Thread {
private:
pthread_t thread_id;
public:
Thread() : thread_id(0) {}
pthread_t &get_thread_id() { return thread_id; }
bool is_started() { return thread_id != 0; }
virtual void *entry() = 0;
private:
static void *_entry_func(void *arg) {
return ((Thread*)arg)->entry();
}
public:
int create() {
return pthread_create( &thread_id, NULL, _entry_func, (void*)this );
}
int join(void **prval = 0) {
if (thread_id == 0) return -1; // never started.
int status = pthread_join(thread_id, prval);
if (status == 0) thread_id = 0;
return status;
}
};
#endif

View File

@ -50,7 +50,7 @@ md_config_t g_conf = {
fake_osdmap_expand: 0,
fake_osd_sync: true,
debug: 1,
debug: 100,
debug_mds_balancer: 1,
debug_mds_log: 1,
debug_buffer: 0,

View File

@ -88,16 +88,17 @@ void BlockDevice::do_io(biovec *bio)
r = _read(bio->start, bio->length, bio->bl);
} else assert(0);
dout(20) << "do_io finish " << (void*)bio << endl;
if (bio->context) {
bio->context->finish(r);
delete bio->context;
delete bio;
}
dout(20) << "do_io finish " << (void*)bio << " " << bio->start << "+" << bio->length << " " << (void*)bio->cond << " " << (void*)bio->context << endl;
if (bio->cond) {
bio->cond->Signal();
bio->rval = r;
}
else if (bio->context) {
bio->context->finish(r);
delete bio->context;
delete bio;
}
}

View File

@ -129,6 +129,7 @@ int Ebofs::write_super()
dout(1) << "write_super v" << super_version << " to b" << bno << endl;
// fill in super
memset(&sb, 0, sizeof(sb));
sb.s_magic = EBOFS_MAGIC;
sb.version = super_version;
sb.num_blocks = dev.get_num_blocks();
@ -167,7 +168,6 @@ int Ebofs::write_super()
Onode* Ebofs::new_onode(object_t oid)
{
Onode* on = new Onode(oid);
on->oc = new ObjectCache(oid, &bc);
assert(onode_map.count(oid) == 0);
onode_map[oid] = on;
@ -204,7 +204,6 @@ Onode* Ebofs::get_onode(object_t oid)
// parse data block
Onode *on = new Onode(oid);
on->oc = new ObjectCache(oid, &bc);
struct ebofs_onode *eo = (struct ebofs_onode*)bl.c_str();
on->onode_loc = eo->onode_loc;
@ -228,6 +227,7 @@ Onode* Ebofs::get_onode(object_t oid)
p += sizeof(Extent);
}
on->get();
return on;
}
@ -323,6 +323,8 @@ void Ebofs::trim_onode_cache()
onode_map.erase(on->object_id);
delete on;
}
dout(10) << "trim_onode_cache " << onode_lru.lru_get_size() << " left" << endl;
}
@ -344,6 +346,7 @@ void Ebofs::trim_buffer_cache()
Onode *on = get_onode( bh->oc->get_object_id() );
bh_write(on, bh);
put_onode(on);
}
// trim bufferheads
@ -361,8 +364,7 @@ void Ebofs::trim_buffer_cache()
if (oc->is_empty()) {
Onode *on = get_onode( oc->get_object_id() );
dout(10) << "trim_buffer_cache closing oc on " << *on << endl;
delete oc;
on->oc = 0;
on->close_oc();
put_onode(on);
}
}
@ -401,6 +403,7 @@ void Ebofs::flush_all()
if (bh->ioh) continue;
Onode *on = get_onode(bh->oc->get_object_id());
bh_write(on, bh);
put_onode(on);
}
dout(1) << "flush_all submitted" << endl;
@ -490,7 +493,7 @@ void Ebofs::bh_write(Onode *on, BufferHead *bh)
void Ebofs::apply_write(Onode *on, size_t len, off_t off, bufferlist& bl)
{
ObjectCache *oc = on->oc;
ObjectCache *oc = on->get_oc(&bc);
// map into blocks
off_t opos = off; // byte pos in object

View File

@ -61,8 +61,9 @@ class Ebofs {
void remove_onode(Onode *on);
void put_onode(Onode* o); // put it back down. ref--.
public:
void trim_onode_cache();
protected:
// ** buffer cache **
BufferCache bc;

View File

@ -69,11 +69,28 @@ public:
void get() {
if (ref == 0) lru_pin();
ref++;
cout << "onode.get " << ref << endl;
}
void put() {
ref--;
if (ref == 0) lru_unpin();
cout << "onode.put " << ref << endl;
}
ObjectCache *get_oc(BufferCache *bc) {
if (!oc) {
oc = new ObjectCache(object_id, bc);
get();
}
return oc;
}
void close_oc() {
assert(oc);
delete oc;
oc = 0;
put();
}
// allocation
int map_extents(block_t start, block_t len, vector<Extent>& ls) {

View File

@ -35,8 +35,10 @@ int main(int argc, char **argv)
fs.flush_all();
fs.trim_buffer_cache();
fs.trim_onode_cache();
fs.umount();
dev.close();
}

View File

@ -150,6 +150,8 @@ class buffer {
return _dataptr;
}
bool has_free_func() { return free_func != 0; }
// accessor
unsigned alloc_length() {
return _alloc_len;
@ -259,7 +261,7 @@ class bufferptr {
// accessors for my subset
char *c_str() {
return _buffer->_dataptr + _off;
return _buffer->c_str() + _off;
}
unsigned length() {
return _len;

View File

@ -32,8 +32,8 @@ class bufferlist {
bufferlist() : _len(0) {
bdbout(1) << "bufferlist.cons " << this << endl;
}
bufferlist(bufferlist& bl) : _len(0) {
assert(0); // o(n) and stupid
bufferlist(const bufferlist& bl) : _len(0) {
//assert(0); // o(n) and stupid
bdbout(1) << "bufferlist.cons " << this << endl;
_buffers = bl._buffers;
_len = bl._len;
@ -44,6 +44,7 @@ class bufferlist {
bufferlist& operator=(bufferlist& bl) {
//assert(0); // actually, this should be fine, just slow (O(n)) and stupid.
bdbout(1) << "bufferlist.= " << this << endl;
_buffers = bl._buffers;
_len = bl._len;
return *this;
@ -207,6 +208,19 @@ class bufferlist {
assert(curbuf != _buffers.end());
}
}
void copy_in(unsigned off, unsigned len, bufferlist& bl) {
unsigned left = len;
for (list<bufferptr>::iterator i = bl._buffers.begin();
i != bl._buffers.end();
i++) {
unsigned l = (*i).length();
if (l > left) l = left;
copy_in(off, l, (*i).c_str());
left -= l;
if (left == 0) break;
off += l;
}
}
void append(const char *data, unsigned len) {
@ -265,6 +279,7 @@ class bufferlist {
for (list<bufferptr>::iterator it = _buffers.begin();
it != _buffers.end();
it++) {
assert((*(*it)).has_free_func() == false); // not allowed if there's a funky free_func.. -sage
memcpy(newbuf.c_str() + off,
(*it).c_str(), (*it).length());
off += (*it).length();