From 1ac107a0b40130317f9bc2e3955ecc587c8207fa Mon Sep 17 00:00:00 2001 From: sage Date: Sat, 21 Jan 2006 01:28:12 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@577 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/config.cc | 20 ++++--- ceph/config.h | 7 ++- ceph/ebofs/BlockDevice.cc | 21 ++++--- ceph/ebofs/BlockDevice.h | 2 +- ceph/include/buffer.h | 6 +- ceph/osd/FakeStore.cc | 112 ++++++++++++++++++++++++++------------ ceph/osd/FakeStore.h | 37 +++++++++++++ ceph/osd/OSD.cc | 3 +- ceph/script/sum.pl | 1 + 9 files changed, 150 insertions(+), 59 deletions(-) diff --git a/ceph/config.cc b/ceph/config.cc index 27935d8b9c147..4746443f2fd32 100644 --- a/ceph/config.cc +++ b/ceph/config.cc @@ -110,23 +110,24 @@ md_config_t g_conf = { // --- osd --- osd_pg_bits: 10, osd_max_rep: 4, - osd_fsync: true, - osd_writesync: false, osd_maxthreads: 10, // 0 == no threading osd_mkfs: false, - osd_fakestore_syncthreads: 4, + fakestore_fsync: true, + fakestore_writesync: false, + fakestore_syncthreads: 4, + fakestore_fakeattr: true, // --- ebofs --- ebofs: 0, ebofs_commit_interval: 2, // seconds. 0 = no timeout (for debugging/tracing) ebofs_oc_size: 1000, ebofs_cc_size: 1000, - ebofs_bc_size: (150 *256), // 4k blocks, or *256 for MB + ebofs_bc_size: (150 *256), // 4k blocks, *256 for MB ebofs_bc_max_dirty: (100 *256), // before write() will block ebofs_abp_zero: false, // zero newly allocated buffers (may shut up valgrind) - ebofs_abp_max_alloc: 4096*16, // max size of new buffers (larger may induce fragmentation) + ebofs_abp_max_alloc: 4096*16, // max size of new buffers (larger -> more memory fragmentation) // --- block device --- bdev_iothreads: 1, // number of ios to queue with kernel @@ -291,11 +292,16 @@ void parse_config_options(vector& args) else if (strcmp(args[i], "--ebofs") == 0) g_conf.ebofs = 1; + else if (strcmp(args[i], "--fakestore") == 0) { g_conf.ebofs = 0; g_conf.fake_osd_sync = 2; g_conf.osd_pg_bits = 3; } + else if (strcmp(args[i], "--fakestore_fsync") == 0) + g_conf.fakestore_fsync = atoi(args[++i]); + else if (strcmp(args[i], "--fakestore_writesync") == 0) + g_conf.fakestore_writesync = atoi(args[++i]); else if (strcmp(args[i], "--osd_mkfs") == 0) g_conf.osd_mkfs = atoi(args[++i]); @@ -303,10 +309,6 @@ void parse_config_options(vector& args) g_conf.osd_pg_bits = atoi(args[++i]); else if (strcmp(args[i], "--osd_max_rep") == 0) g_conf.osd_max_rep = atoi(args[++i]); - else if (strcmp(args[i], "--osd_fsync") == 0) - g_conf.osd_fsync = atoi(args[++i]); - else if (strcmp(args[i], "--osd_writesync") == 0) - g_conf.osd_writesync = atoi(args[++i]); else if (strcmp(args[i], "--osd_maxthreads") == 0) g_conf.osd_maxthreads = atoi(args[++i]); diff --git a/ceph/config.h b/ceph/config.h index a7ce5e48945ac..8782968e2cad8 100644 --- a/ceph/config.h +++ b/ceph/config.h @@ -84,12 +84,13 @@ struct md_config_t { // osd int osd_pg_bits; int osd_max_rep; - bool osd_fsync; - bool osd_writesync; int osd_maxthreads; bool osd_mkfs; - int osd_fakestore_syncthreads; // such crap + bool fakestore_fsync; + bool fakestore_writesync; + int fakestore_syncthreads; // such crap + bool fakestore_fakeattr; // ebofs int ebofs; diff --git a/ceph/ebofs/BlockDevice.cc b/ceph/ebofs/BlockDevice.cc index 7c5a95df0e5ff..249b3d54f3840 100644 --- a/ceph/ebofs/BlockDevice.cc +++ b/ceph/ebofs/BlockDevice.cc @@ -88,13 +88,16 @@ int BlockDevice::io_thread_entry() // merge contiguous ops list biols; char type = i->second->type; - int n = 0; + int n = 0; // count eventual iov's for readv/writev el_pos = i->first; - while (el_pos == i->first && type == i->second->type && // while (contiguous) - ++n <= g_conf.bdev_iov_max) { // and not too big + while (el_pos == i->first && type == i->second->type) { // while (contiguous) biovec *bio = i->second; + int nv = bio->bl.buffers().size(); // how many iov's in this bio's bufferlist? + if (n + nv >= g_conf.bdev_iov_max) break; + n += nv; + if (el_dir_forward) { dout(20) << "io_thread" << whoami << " fw dequeue io at " << el_pos << " " << *i->second << endl; biols.push_back(bio); // at back @@ -469,9 +472,10 @@ int BlockDevice::open() // start thread io_threads_started = 0; + io_threads.clear(); for (int i=0; icreate(); } complete_thread.create(); @@ -494,8 +498,11 @@ int BlockDevice::close() lock.Unlock(); - for (int i=0; ijoin(); + delete io_threads[i]; + } + io_threads.clear(); complete_thread.join(); diff --git a/ceph/ebofs/BlockDevice.h b/ceph/ebofs/BlockDevice.h index c0bdce3c419a0..17b7134fea055 100644 --- a/ceph/ebofs/BlockDevice.h +++ b/ceph/ebofs/BlockDevice.h @@ -74,7 +74,7 @@ class BlockDevice { IOThread(BlockDevice *d) : dev(d) {} void *entry() { return (void*)dev->io_thread_entry(); } } ; - vector io_threads; + vector io_threads; // low level io int _read(int fd, block_t bno, unsigned num, bufferlist& bl); diff --git a/ceph/include/buffer.h b/ceph/include/buffer.h index 68781fe6e3d13..1178498ef47db 100644 --- a/ceph/include/buffer.h +++ b/ceph/include/buffer.h @@ -330,9 +330,9 @@ class bufferptr { inline ostream& operator<<(ostream& out, bufferptr& bp) { - return out << "bufferptr(len=" << bp._len << ", off=" << bp._off - << ", int=" << *(int*)(bp.c_str()) - << ", " << *bp._buffer + return out << "bufferptr(len=" << bp._len << " off=" << bp._off + << " cstr=" << (void*)bp.c_str() + << " buf=" << *bp._buffer << ")"; } diff --git a/ceph/osd/FakeStore.cc b/ceph/osd/FakeStore.cc index e01ae73b9d6c8..07c6958a7a772 100644 --- a/ceph/osd/FakeStore.cc +++ b/ceph/osd/FakeStore.cc @@ -32,7 +32,7 @@ using namespace __gnu_cxx; // end crap hash -map > > fakeattrs; + FakeStore::FakeStore(char *base, int whoami) @@ -60,7 +60,7 @@ int FakeStore::mount() { char name[80]; sprintf(name,"osd%d.fakestore.threadpool", whoami); - fsync_threadpool = new ThreadPool >(name, g_conf.osd_fakestore_syncthreads, + fsync_threadpool = new ThreadPool >(name, g_conf.fakestore_syncthreads, (void (*)(FakeStore*, pair*))dofsync, this); } @@ -271,7 +271,7 @@ int FakeStore::write(object_t oid, ::mknod(fn.c_str(), 0644, 0); // in case it doesn't exist yet. int flags = O_WRONLY;//|O_CREAT; - if (do_fsync && g_conf.osd_writesync) flags |= O_SYNC; + if (do_fsync && g_conf.fakestore_writesync) flags |= O_SYNC; int fd = ::open(fn.c_str(), flags); if (fd < 0) { dout(1) << "write couldn't open " << fn.c_str() << " flags " << flags << " errno " << errno << " " << strerror(errno) << endl; @@ -302,7 +302,7 @@ int FakeStore::write(object_t oid, } // sync to to disk? - if (do_fsync && g_conf.osd_fsync) ::fsync(fd); // fsync or fdatasync? + if (do_fsync && g_conf.fakestore_fsync) ::fsync(fd); // fsync or fdatasync? ::flock(fd, LOCK_UN); ::close(fd); @@ -371,10 +371,11 @@ int FakeStore::write(object_t oid, int FakeStore::setattr(object_t oid, const char *name, void *value, size_t size) { - if (1) { - bufferptr bp(new buffer((char*)value,size)); - fakeattrs[whoami][oid][name] = bp; - return 0; + if (g_conf.fakestore_fakeattr) { + lock.Lock(); + int r = fakeoattrs[oid].setattr(name, value, size); + lock.Unlock(); + return r; } else { string fn; get_oname(oid, fn); @@ -390,17 +391,11 @@ int FakeStore::setattr(object_t oid, const char *name, int FakeStore::getattr(object_t oid, const char *name, void *value, size_t size) { - if (1) { - if (fakeattrs[whoami][oid].count(name)) { - size_t l = fakeattrs[whoami][oid][name].length(); - if (l > size) l = size; - bufferlist bl; - bl.append(fakeattrs[whoami][oid][name]); - bl.copy(0, l, (char*)value); - return l; - } else { - return -1; - } + if (g_conf.fakestore_fakeattr) { + lock.Lock(); + int r = fakeoattrs[oid].getattr(name, value, size); + lock.Unlock(); + return r; } else { string fn; get_oname(oid, fn); @@ -412,9 +407,16 @@ int FakeStore::getattr(object_t oid, const char *name, int FakeStore::listattr(object_t oid, char *attrs, size_t size) { - string fn; - get_oname(oid, fn); - return listxattr(fn.c_str(), attrs, size); + if (g_conf.fakestore_fakeattr) { + lock.Lock(); + int r = fakeoattr[oid].listattr(attrs,size); + lock.Unlock(); + return r; + } else { + string fn; + get_oname(oid, fn); + return listxattr(fn.c_str(), attrs, size); + } } @@ -465,22 +467,27 @@ int FakeStore::open_collection(coll_t c) { // public int FakeStore::list_collections(list& ls) { + lock.Lock(); if (!collections.is_open()) open_collections(); ls.clear(); collections.list_keys(ls); + lock.Unlock(); return 0; } int FakeStore::create_collection(coll_t c) { + lock.Lock(); if (!collections.is_open()) open_collections(); collections.put(c, 1); open_collection(c); + lock.Unlock(); return 0; } int FakeStore::destroy_collection(coll_t c) { + lock.Lock(); if (!collections.is_open()) open_collections(); collections.del(c); @@ -493,72 +500,107 @@ int FakeStore::destroy_collection(coll_t c) { collection_map[c]->remove(fn.c_str()); delete collection_map[c]; collection_map.erase(c); + lock.Unlock(); return 0; } int FakeStore::collection_stat(coll_t c, struct stat *st) { + lock.Lock(); if (!collections.is_open()) open_collections(); string fn; get_collfn(c,fn); - return ::stat(fn.c_str(), st); + int r = ::stat(fn.c_str(), st); + lock.Unlock(); + return r; } bool FakeStore::collection_exists(coll_t c) { + lock.Lock(); struct stat st; - return collection_stat(c, &st) == 0; + int r = collection_stat(c, &st) == 0; + lock.Unlock(); + return r; } int FakeStore::collection_add(coll_t c, object_t o) { + lock.Lock(); if (!collections.is_open()) open_collections(); open_collection(c); collection_map[c]->put(o,1); + lock.Unlock(); return 0; } int FakeStore::collection_remove(coll_t c, object_t o) { + lock.Lock(); if (!collections.is_open()) open_collections(); open_collection(c); collection_map[c]->del(o); + lock.Unlock(); return 0; } int FakeStore::collection_list(coll_t c, list& o) { + lock.Lock(); if (!collections.is_open()) open_collections(); open_collection(c); collection_map[c]->list_keys(o); + lock.Unlock(); return 0; } int FakeStore::collection_setattr(coll_t cid, const char *name, void *value, size_t size) { + int r; + lock.Lock(); if (!collections.is_open()) open_collections(); - - string fn; - get_collfn(cid,fn); - return setxattr(fn.c_str(), name, value, size, 0); + if (g_conf.fakestore_fakeattr) { + r = fakeoattrs[oid].setattr(name, value, size); + } else { + string fn; + get_collfn(cid,fn); + r = setxattr(fn.c_str(), name, value, size, 0); + } + lock.Unlock(); + return r; } int FakeStore::collection_getattr(coll_t cid, const char *name, void *value, size_t size) { + int r; + lock.Lock(); if (!collections.is_open()) open_collections(); - - string fn; - get_collfn(cid,fn); - return getxattr(fn.c_str(), name, value, size); + if (g_conf.fakestore_fakeattr) { + r = fakecattrs[cid].getattr(name, value, size); + } else { + string fn; + get_collfn(cid,fn); + r = getxattr(fn.c_str(), name, value, size); + } + lock.Unlock(); + return r; } int FakeStore::collection_listattr(coll_t cid, char *attrs, size_t size) { + int r; + lock.Lock(); if (!collections.is_open()) open_collections(); - string fn; - get_collfn(cid, fn); - return listxattr(fn.c_str(), attrs, size); + if (g_conf.fakestore_fakeattr) { + r = fakecattr[cid].listattr(attrs,size); + } else { + string fn; + get_collfn(cid, fn); + r = listxattr(fn.c_str(), attrs, size); + } + lock.Unlock(); + return r; } diff --git a/ceph/osd/FakeStore.h b/ceph/osd/FakeStore.h index e1c5b730fc959..d27541dc2e4cc 100644 --- a/ceph/osd/FakeStore.h +++ b/ceph/osd/FakeStore.h @@ -4,15 +4,52 @@ #include "ObjectStore.h" #include "BDBMap.h" #include "common/ThreadPool.h" +#include "common/Mutex.h" #include using namespace std; +// fake attributes in memory, if we need to. + +class FakeAttrSet { + public: + map attrs; + + int getattr(char *name, void *value, size_t size) { + if (attrs.count(name)) { + size_t l = attrs[name].length(); + if (l > size) l = size; + bufferlist bl; + bl.append(attrs[name]); + bl.copy(0, l, (char*)value); + return l; + } + return -1; + } + + int setattr(char *name, void *value, size_t size) { + bufferptr bp(new buffer((char*)value,size)); + attrs[name] = bp; + return 0; + } + + int listattr(char *attrs, size_t size) { + assert(0); + } + + bool empty() { return attrs.empty(); } +}; + + class FakeStore : public ObjectStore { string basedir; int whoami; + Mutex lock; + hash_map fakeoattrs; + hash_map fakecattrs; + // fns void get_dir(string& dir); void get_oname(object_t oid, string& fn); diff --git a/ceph/osd/OSD.cc b/ceph/osd/OSD.cc index c5b50b88ef548..13d46df7864e2 100644 --- a/ceph/osd/OSD.cc +++ b/ceph/osd/OSD.cc @@ -1808,7 +1808,8 @@ void OSD::op_rep_modify(MOSDOp *op) version_t ov = 0; if (store->exists(oid)) store->getattr(oid, "version", &ov, sizeof(ov)); - //dout(15) << "rep_modify old versoin is " << ov << " msg sez " << op->get_old_version() << endl; + if (op->get_old_version() != ov) + dout(0) << "rep_modify old version is " << ov << " msg sez " << op->get_old_version() << endl; assert(op->get_old_version() == ov); // PG diff --git a/ceph/script/sum.pl b/ceph/script/sum.pl index d4ff59f4589fe..d6385707c4bb6 100755 --- a/ceph/script/sum.pl +++ b/ceph/script/sum.pl @@ -91,6 +91,7 @@ my $rows = $n; my $files = $tcount{$starttime}; print "\n"; +print join("\t",'#', map { $col{$_} } @c) . "\n"; print join("\t", '#minval', map { $min{$col{$_}} } @c ) . "\n"; print join("\t", '#maxval', map { $max{$col{$_}} } @c ) . "\n"; print join("\t", '#rows', map { $rows } @c) . "\n"; -- 2.39.5