From c728d594fffa28d7c885863033f1c67f24fc1c92 Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 12 Mar 2007 03:13:33 +0000 Subject: [PATCH] merged trunk changes r1171:1207 into branches/sage/cephmds2 (take 2, worked better this time.) git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1210 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/cephmds2/Makefile | 2 +- branches/sage/cephmds2/cfuse.cc | 3 + branches/sage/cephmds2/client/Client.cc | 16 +- branches/sage/cephmds2/client/FileCache.cc | 9 + branches/sage/cephmds2/client/FileCache.h | 5 + branches/sage/cephmds2/client/fuse.cc | 2 - branches/sage/cephmds2/common/Logger.cc | 8 + branches/sage/cephmds2/common/Thread.h | 4 +- branches/sage/cephmds2/common/Timer.cc | 6 +- branches/sage/cephmds2/config.cc | 4 +- branches/sage/cephmds2/config.h | 4 +- branches/sage/cephmds2/ebofs/BlockDevice.h | 7 + branches/sage/cephmds2/ebofs/Table.h | 5 +- branches/sage/cephmds2/fakefuse.cc | 4 +- branches/sage/cephmds2/fakesyn.cc | 36 +- branches/sage/cephmds2/include/Context.h | 45 ++- branches/sage/cephmds2/jobs/example | 56 +++ branches/sage/cephmds2/mds/MDS.cc | 4 + branches/sage/cephmds2/messages/MOSDOp.h | 8 +- branches/sage/cephmds2/mon/MonitorStore.cc | 7 +- branches/sage/cephmds2/mon/OSDMonitor.cc | 2 + branches/sage/cephmds2/msg/FakeMessenger.cc | 68 ++-- branches/sage/cephmds2/osbdb/OSBDB.cc | 368 ++++++++++++++++---- branches/sage/cephmds2/osd/OSD.cc | 12 +- branches/sage/cephmds2/osdc/Journaler.cc | 4 +- branches/sage/cephmds2/osdc/ObjectCacher.cc | 112 +++--- branches/sage/cephmds2/osdc/ObjectCacher.h | 40 ++- branches/sage/cephmds2/osdc/Objecter.cc | 123 ++++--- branches/sage/cephmds2/script/runset.pl | 2 +- branches/sage/cephmds2/test/testos.cc | 3 +- branches/sage/cephmds2/test/testosbdb.cc | 134 ++++++- 31 files changed, 803 insertions(+), 300 deletions(-) create mode 100644 branches/sage/cephmds2/jobs/example diff --git a/branches/sage/cephmds2/Makefile b/branches/sage/cephmds2/Makefile index 015b10c9f5c40..575b32a75dcb5 100644 --- a/branches/sage/cephmds2/Makefile +++ b/branches/sage/cephmds2/Makefile @@ -110,7 +110,7 @@ OSBDB_OBJS = \ OSBDB_OBJ = osbdb.o endif -TARGETS = cmon cosd cmds cfuse csyn newsyn fakesyn mkmonmap cmonctl +TARGETS = cmon cosd cmds csyn newsyn fakesyn mkmonmap cmonctl cfuse fakefuse SRCS=*.cc */*.cc *.h */*.h */*/*.h diff --git a/branches/sage/cephmds2/cfuse.cc b/branches/sage/cephmds2/cfuse.cc index 3c73c3d885a19..4b7e490c26b76 100644 --- a/branches/sage/cephmds2/cfuse.cc +++ b/branches/sage/cephmds2/cfuse.cc @@ -43,6 +43,9 @@ int main(int argc, char **argv, char *envp[]) { // args for fuse vec_to_argv(args, argc, argv); + // FUSE will chdir("/"); be ready. + g_conf.use_abspaths = true; + // load monmap MonMap monmap; int r = monmap.read(".ceph_monmap"); diff --git a/branches/sage/cephmds2/client/Client.cc b/branches/sage/cephmds2/client/Client.cc index 6d09efa823ef4..5554c94f8836b 100644 --- a/branches/sage/cephmds2/client/Client.cc +++ b/branches/sage/cephmds2/client/Client.cc @@ -129,13 +129,19 @@ Client::Client(Messenger *m, MonMap *mm) Client::~Client() { - if (messenger) { delete messenger; messenger = 0; } + tear_down_cache(); + + if (objectcacher) { + delete objectcacher; + objectcacher = 0; + } + if (filer) { delete filer; filer = 0; } - if (objectcacher) { delete objectcacher; objectcacher = 0; } if (objecter) { delete objecter; objecter = 0; } if (osdmap) { delete osdmap; osdmap = 0; } + if (mdsmap) { delete mdsmap; mdsmap = 0; } - tear_down_cache(); + if (messenger) { delete messenger; messenger = 0; } } @@ -886,6 +892,7 @@ void Client::handle_file_caps(MClientFileCaps *m) if (cap_reap_queue[in->ino()].empty()) cap_reap_queue.erase(in->ino()); } + delete m; return; } @@ -913,7 +920,7 @@ void Client::handle_file_caps(MClientFileCaps *m) } else { //dout(0) << "didn't put_inode" << endl; } - + delete m; return; } @@ -973,7 +980,6 @@ void Client::handle_file_caps(MClientFileCaps *m) } } in->fc.set_caps(new_caps, onimplement); - } else { // caching off. diff --git a/branches/sage/cephmds2/client/FileCache.cc b/branches/sage/cephmds2/client/FileCache.cc index 5d572ab7b670c..2a1dd1576ae59 100644 --- a/branches/sage/cephmds2/client/FileCache.cc +++ b/branches/sage/cephmds2/client/FileCache.cc @@ -50,6 +50,15 @@ void FileCache::empty(Context *onempty) } +void FileCache::tear_down() +{ + off_t unclean = release_clean(); + if (unclean) { + dout(0) << "tear_down " << unclean << " unclean bytes, purging" << endl; + oc->purge_set(inode.ino); + } +} + // caps void FileCache::set_caps(int caps, Context *onimplement) diff --git a/branches/sage/cephmds2/client/FileCache.h b/branches/sage/cephmds2/client/FileCache.h index 742ec98733d9b..6bef22f4e0c6a 100644 --- a/branches/sage/cephmds2/client/FileCache.h +++ b/branches/sage/cephmds2/client/FileCache.h @@ -34,6 +34,9 @@ class FileCache { latest_caps(0), num_reading(0), num_writing(0),// num_unsafe(0), waitfor_release(false) {} + ~FileCache() { + tear_down(); + } // waiters/waiting bool can_read() { return latest_caps & CAP_FILE_RD; } @@ -52,6 +55,8 @@ class FileCache { bool is_cached(); bool is_dirty(); + void tear_down(); + int get_caps() { return latest_caps; } void set_caps(int caps, Context *onimplement=0); void check_caps(); diff --git a/branches/sage/cephmds2/client/fuse.cc b/branches/sage/cephmds2/client/fuse.cc index 86a2ce3602315..f4a1c2d3f7797 100644 --- a/branches/sage/cephmds2/client/fuse.cc +++ b/branches/sage/cephmds2/client/fuse.cc @@ -276,8 +276,6 @@ int ceph_fuse_main(Client *c, int argc, char *argv[]) // go fuse go cout << "ok, calling fuse_main" << endl; - cout << "cwd was " << get_current_dir_name() << endl; int r = fuse_main(newargc, newargv, &ceph_oper); - cout << "cwd now " << get_current_dir_name() << endl; return r; } diff --git a/branches/sage/cephmds2/common/Logger.cc b/branches/sage/cephmds2/common/Logger.cc index bb9923d6a2cd3..91164658a80e5 100644 --- a/branches/sage/cephmds2/common/Logger.cc +++ b/branches/sage/cephmds2/common/Logger.cc @@ -34,6 +34,14 @@ Logger::Logger(string fn, LogType *type) { logger_lock.Lock(); { + filename = ""; + if (g_conf.use_abspaths) { + char *cwd = get_current_dir_name(); + filename = cwd; + delete cwd; + filename += "/"; + } + filename = "log/"; if (g_conf.log_name) { filename += g_conf.log_name; diff --git a/branches/sage/cephmds2/common/Thread.h b/branches/sage/cephmds2/common/Thread.h index 43e2942e84c5f..8565ce9effd92 100644 --- a/branches/sage/cephmds2/common/Thread.h +++ b/branches/sage/cephmds2/common/Thread.h @@ -45,7 +45,9 @@ class Thread { } int join(void **prval = 0) { - if (thread_id == 0) return -1; // never started. + assert(thread_id); + //if (thread_id == 0) return -1; // never started. + int status = pthread_join(thread_id, prval); if (status == 0) thread_id = 0; diff --git a/branches/sage/cephmds2/common/Timer.cc b/branches/sage/cephmds2/common/Timer.cc index adacf0c5eb6c6..522a623d5ebac 100644 --- a/branches/sage/cephmds2/common/Timer.cc +++ b/branches/sage/cephmds2/common/Timer.cc @@ -234,6 +234,10 @@ bool Timer::cancel_event(Context *callback) scheduled.erase(tp); lock.Unlock(); + + // delete the canceled event. + delete callback; + return true; } @@ -290,7 +294,7 @@ void SafeTimer::cancel_event(Context *c) if (g_timer.cancel_event(scheduled[c])) { // hosed wrapper. hose original event too. - delete scheduled[c]; + delete c; } else { // clean up later. canceled[c] = scheduled[c]; diff --git a/branches/sage/cephmds2/config.cc b/branches/sage/cephmds2/config.cc index 3aee3ae8037c7..ddbc606b726c1 100644 --- a/branches/sage/cephmds2/config.cc +++ b/branches/sage/cephmds2/config.cc @@ -103,6 +103,9 @@ md_config_t g_conf = { debug_after: 0, + // -- misc -- + use_abspaths: false, // make monitorstore et al use absolute path (to workaround FUSE chdir("/")) + // --- clock --- clock_lock: false, @@ -130,7 +133,6 @@ md_config_t g_conf = { mon_osd_down_out_interval: 5, // seconds mon_lease: 2.000, // seconds mon_stop_with_last_mds: true, - mon_store_abspath: false, // make monitorstore use absolute path (to workaround fakefuse idiocy) // --- client --- client_cache_size: 300, diff --git a/branches/sage/cephmds2/config.h b/branches/sage/cephmds2/config.h index d6e3b5142565c..b507556e0c01c 100644 --- a/branches/sage/cephmds2/config.h +++ b/branches/sage/cephmds2/config.h @@ -81,6 +81,9 @@ struct md_config_t { int debug_after; + // misc + bool use_abspaths; + // clock bool clock_lock; @@ -108,7 +111,6 @@ struct md_config_t { int mon_osd_down_out_interval; float mon_lease; bool mon_stop_with_last_mds; - bool mon_store_abspath; // client int client_cache_size; diff --git a/branches/sage/cephmds2/ebofs/BlockDevice.h b/branches/sage/cephmds2/ebofs/BlockDevice.h index 25adf62606947..18f639f7176b6 100644 --- a/branches/sage/cephmds2/ebofs/BlockDevice.h +++ b/branches/sage/cephmds2/ebofs/BlockDevice.h @@ -143,6 +143,13 @@ class BlockDevice { BarrierQueue(BlockDevice *bd, const char *d) : bdev(bd), dev(d) { barrier(); } + ~BarrierQueue() { + for (list::iterator p = qls.begin(); + p != qls.end(); + ++p) + delete *p; + qls.clear(); + } int size() { // this isn't perfectly accurate. if (!qls.empty()) diff --git a/branches/sage/cephmds2/ebofs/Table.h b/branches/sage/cephmds2/ebofs/Table.h index e6b3fb39660e4..f16e506a9dd63 100644 --- a/branches/sage/cephmds2/ebofs/Table.h +++ b/branches/sage/cephmds2/ebofs/Table.h @@ -666,8 +666,9 @@ class Table { assert(cursor.open[cursor.level].size() == 0); assert(depth == 1); root = -1; - depth = 0; - pool.release(cursor.open[0].node); + depth = 0; + if (cursor.open[0].node) + pool.release(cursor.open[0].node); } verify("remove 1"); return 0; diff --git a/branches/sage/cephmds2/fakefuse.cc b/branches/sage/cephmds2/fakefuse.cc index 1b8c526069711..2edf3c7930e7a 100644 --- a/branches/sage/cephmds2/fakefuse.cc +++ b/branches/sage/cephmds2/fakefuse.cc @@ -75,8 +75,8 @@ int main(int argc, char **argv) { args = nargs; vec_to_argv(args, argc, argv); - // make monitorstore use abspath, since fuse seems to screw with the cwd - g_conf.mon_store_abspath = true; + // FUSE will chdir("/"); be ready. + g_conf.use_abspaths = true; MonMap *monmap = new MonMap(g_conf.num_mon); diff --git a/branches/sage/cephmds2/fakesyn.cc b/branches/sage/cephmds2/fakesyn.cc index dca78939b9282..d4fc63a4cbba8 100644 --- a/branches/sage/cephmds2/fakesyn.cc +++ b/branches/sage/cephmds2/fakesyn.cc @@ -31,9 +31,6 @@ using namespace std; #include "common/Timer.h" -#define NUMMDS g_conf.num_mds -#define NUMOSD g_conf.num_osd -#define NUMCLIENT g_conf.num_client class C_Test : public Context { public: @@ -97,9 +94,9 @@ int main(int argc, char **argv) } // create mds - MDS *mds[NUMMDS]; - OSD *mdsosd[NUMMDS]; - for (int i=0; iinit(); } - for (int i=0; iinit(); if (g_conf.mds_local_osd) mdsosd[i]->init(); } - for (int i=0; iinit(); } // create client(s) - for (int i=0; iinit(); // use my argc, argv (make sure you pass a mount point!) @@ -158,7 +155,7 @@ int main(int argc, char **argv) } - for (int i=0; ijoin_thread(); @@ -174,13 +171,16 @@ int main(int argc, char **argv) fakemessenger_wait(); // cleanup - for (int i=0; ifinish(0); + delete onfinish; + onfinish = 0; + return true; + } + class C_GatherSub : public Context { C_Gather *gather; int num; public: C_GatherSub(C_Gather *g, int n) : gather(g), num(n) {} void finish(int r) { - gather->finish(num); + if (gather->sub_finish(num)) + delete gather; // last one! } }; + Context *new_sub() { + num++; + waitfor.insert(num); + return new C_GatherSub(this, num); + } + private: Context *onfinish; std::set waitfor; int num; public: - C_Gather(Context *f) : onfinish(f), num(0) {} - + C_Gather(Context *f) : onfinish(f), num(0) { + //cout << "C_Gather new " << this << endl; + } + ~C_Gather() { + //cout << "C_Gather delete " << this << endl; + assert(!onfinish); + } void finish(int r) { - assert(waitfor.count(r)); - waitfor.erase(r); - if (waitfor.empty()) { - onfinish->finish(0); - delete onfinish; - } + // nobody should ever call me. + assert(0); } - Context *new_sub() { - num++; - waitfor.insert(num); - return new C_GatherSub(this, num); - } }; #endif diff --git a/branches/sage/cephmds2/jobs/example b/branches/sage/cephmds2/jobs/example new file mode 100644 index 0000000000000..802a8b66e6332 --- /dev/null +++ b/branches/sage/cephmds2/jobs/example @@ -0,0 +1,56 @@ +#!/usr/bin/perl +# hi there +{ + # startup + 'n' => 30, # number of mpi nodes + 'sleep' => 3, # seconds to sleep between runs (so you have time to control-c out) + 'nummds' => 1, + 'numosd' => 6, + 'numclient' => 100, + + 'until' => 100, # --syn until $n ... synthetic client will stop itself after this many seconds. + 'kill_after' => 300, # seconds before everything commits suicide (in case something hangs) + + # stuff i want to vary + # here's a simple example: + + # do --syn writefile command + 'writefile' => 1, + # and very the write size + 'writefile_size' => [ # vary +# 2048*1024, + 1024*1024, + 512*1024, + 256*1024, + 128*1024, + 64*1024, + 48*1024, + 32*1024, + 28*1024, + 24*1024, + 16*1024, + 12*1024, + 8*1024, + 4096, +# 256, +# 16, +# 1 + ], + 'writefile_mb' => 1000, # each client shoudl write 1GB (or more likely, keep going until time runs out) + + 'file_layout_num_rep'=> [1,2], # also vary the replication level + + # pass some other random things to newsyn + 'custom' => '--', + + # for final summation (script/sum.pl) + # specify time period to look at the results + 'start' => 30, # skip first 30 seconds, so that caches are full etc. + 'end' => 90, # go for 60 seconds + + # what should i parse/plot? + 'comb' => { + 'x' => 'writefile_size', + 'vars' => [ 'osd.c_wrb', 'osd.r_wrb' ], + } +}; diff --git a/branches/sage/cephmds2/mds/MDS.cc b/branches/sage/cephmds2/mds/MDS.cc index d0f58817b314c..c040bc1ee314b 100644 --- a/branches/sage/cephmds2/mds/MDS.cc +++ b/branches/sage/cephmds2/mds/MDS.cc @@ -121,6 +121,10 @@ MDS::~MDS() { if (anchormgr) { delete anchormgr; anchormgr = NULL; } if (anchorclient) { delete anchorclient; anchorclient = NULL; } if (osdmap) { delete osdmap; osdmap = 0; } + if (mdsmap) { delete mdsmap; mdsmap = 0; } + + if (server) { delete server; server = 0; } + if (locker) { delete locker; locker = 0; } if (filer) { delete filer; filer = 0; } if (objecter) { delete objecter; objecter = 0; } diff --git a/branches/sage/cephmds2/messages/MOSDOp.h b/branches/sage/cephmds2/messages/MOSDOp.h index 6139df56d833e..d16b02e8aad51 100644 --- a/branches/sage/cephmds2/messages/MOSDOp.h +++ b/branches/sage/cephmds2/messages/MOSDOp.h @@ -93,7 +93,9 @@ private: eversion_t pg_trim_to; // primary->replica: trim to here int op; - size_t length, offset; + size_t length; + off_t offset; + eversion_t version; eversion_t old_version; @@ -136,7 +138,7 @@ private: void set_op(int o) { st.op = o; } const size_t get_length() { return st.length; } - const size_t get_offset() { return st.offset; } + const off_t get_offset() { return st.offset; } map& get_attrset() { return attrset; } void set_attrset(map &as) { attrset = as; } @@ -183,7 +185,7 @@ private: //void set_rg_nrep(int n) { st.rg_nrep = n; } void set_length(size_t l) { st.length = l; } - void set_offset(size_t o) { st.offset = o; } + void set_offset(off_t o) { st.offset = o; } void set_version(eversion_t v) { st.version = v; } void set_old_version(eversion_t ov) { st.old_version = ov; } diff --git a/branches/sage/cephmds2/mon/MonitorStore.cc b/branches/sage/cephmds2/mon/MonitorStore.cc index 5185eb8206ded..55389973c8c6a 100644 --- a/branches/sage/cephmds2/mon/MonitorStore.cc +++ b/branches/sage/cephmds2/mon/MonitorStore.cc @@ -36,10 +36,12 @@ void MonitorStore::mount() } ::closedir(d); - if (g_conf.mon_store_abspath) { + if (g_conf.use_abspaths) { // combine it with the cwd, in case fuse screws things up (i.e. fakefuse) string old = dir; - dir = get_current_dir_name(); + char *cwd = get_current_dir_name(); + dir = cwd; + delete cwd; dir += "/"; dir += old; } @@ -107,7 +109,6 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) sprintf(tfn, "%s.new", fn); int fd = ::open(tfn, O_WRONLY|O_CREAT); - dout(0) << " fd " << fd << " tfn " << tfn << " " << errno << " " << strerror(errno) << " " << get_current_dir_name() << endl; assert(fd > 0); ::fchmod(fd, 0644); ::write(fd, vs, strlen(vs)); diff --git a/branches/sage/cephmds2/mon/OSDMonitor.cc b/branches/sage/cephmds2/mon/OSDMonitor.cc index 43ec4eddf2eca..fe9d54b189de6 100644 --- a/branches/sage/cephmds2/mon/OSDMonitor.cc +++ b/branches/sage/cephmds2/mon/OSDMonitor.cc @@ -399,6 +399,8 @@ void OSDMonitor::handle_osd_boot(MOSDBoot *m) << (osdmap.osds.size() - osdmap.osd_inst.size()) << " osds to boot" << endl; } + + delete m; return; } diff --git a/branches/sage/cephmds2/msg/FakeMessenger.cc b/branches/sage/cephmds2/msg/FakeMessenger.cc index 5a3aa3a78cc03..7bf68c767e621 100644 --- a/branches/sage/cephmds2/msg/FakeMessenger.cc +++ b/branches/sage/cephmds2/msg/FakeMessenger.cc @@ -143,7 +143,6 @@ int fakemessenger_do_loop_2() dout(18) << "messenger " << mgr << " at " << mgr->get_myname() << " has " << mgr->num_incoming() << " queued" << endl; - if (!mgr->is_ready()) { dout(18) << "messenger " << mgr << " at " << mgr->get_myname() << " has no dispatcher, skipping" << endl; it++; @@ -248,7 +247,11 @@ FakeMessenger::FakeMessenger(entity_name_t me) : Messenger(me) FakeMessenger::~FakeMessenger() { - + // hose any undelivered messages + for (list::iterator p = incoming.begin(); + p != incoming.end(); + ++p) + delete *p; } @@ -259,15 +262,6 @@ int FakeMessenger::shutdown() assert(directory.count(_myinst.addr) == 1); shutdown_set.insert(_myinst.addr); - /* - directory.erase(myaddr); - if (directory.empty()) { - dout(1) << "fakemessenger: last shutdown" << endl; - ::fm_shutdown = true; - cond.Signal(); // why not - } - */ - /* if (loggers[myaddr]) { delete loggers[myaddr]; @@ -303,45 +297,37 @@ int FakeMessenger::send_message(Message *m, entity_inst_t inst, int port, int fr lock.Lock(); - // deliver - try { #ifdef LOG_MESSAGES - // stats - loggers[get_myaddr()]->inc("+send",1); - loggers[dest]->inc("-recv",1); - - char s[20]; - sprintf(s,"+%s", m->get_type_name()); - loggers[get_myaddr()]->inc(s); - sprintf(s,"-%s", m->get_type_name()); - loggers[dest]->inc(s); + // stats + loggers[get_myaddr()]->inc("+send",1); + loggers[dest]->inc("-recv",1); + + char s[20]; + sprintf(s,"+%s", m->get_type_name()); + loggers[get_myaddr()]->inc(s); + sprintf(s,"-%s", m->get_type_name()); + loggers[dest]->inc(s); #endif - // queue - FakeMessenger *dm = directory[inst.addr]; - if (!dm) { - dout(1) << "** destination " << inst << " dne" << endl; - for (map::iterator p = directory.begin(); - p != directory.end(); - ++p) { - dout(1) << "** have " << p->first << " to " << p->second << endl; - } - //assert(dm); - } - dm->queue_incoming(m); - + // queue + if (directory.count(inst.addr)) { dout(1) << "--> " << get_myname() << " -> " << inst.name << " " << *m << " (" << m << ")" << endl; - - } - catch (...) { - cout << "no destination " << dest << endl; - assert(0); + directory[inst.addr]->queue_incoming(m); + } else { + dout(0) << "--> " << get_myname() << " -> " << inst.name << " " << *m + << " *** destination DNE ***" << endl; + for (map::iterator p = directory.begin(); + p != directory.end(); + ++p) { + dout(0) << "** have " << p->first << " to " << p->second << endl; + } + //assert(dm); + delete m; } - // wake up loop? if (!awake) { dout(10) << "waking up fakemessenger thread" << endl; diff --git a/branches/sage/cephmds2/osbdb/OSBDB.cc b/branches/sage/cephmds2/osbdb/OSBDB.cc index 45d5423561a83..a60888a7dbb5a 100644 --- a/branches/sage/cephmds2/osbdb/OSBDB.cc +++ b/branches/sage/cephmds2/osbdb/OSBDB.cc @@ -15,9 +15,9 @@ Foundation. See file COPYING. */ using namespace std; #undef dout -#define dout(x) if (x <= g_conf.debug_bdbstore) cout << "bdbstore(" << device << ")." +#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_bdbstore) cout << "bdbstore(" << device << ")@" << __LINE__ << "." #undef derr -#define derr(x) if (x <= g_conf.debug_bdbstore) cerr << "bdbstore(" << device << ")." +#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_bdbstore) cerr << "bdbstore(" << device << ")@" << __LINE__ << "." // Utilities. @@ -127,13 +127,19 @@ int OSBDB::mount() dout(2) << "mount " << device << endl; if (mounted) - return 0; + { + dout(4) << "..already mounted" << endl; + return 0; + } if (!opened) { int ret; if ((ret = opendb ()) != 0) - return ret; + { + dout(4) << "..returns " << ret << endl; + return ret; + } } // XXX Do we want anything else in the superblock? @@ -146,12 +152,18 @@ int OSBDB::mount() value.set_flags (DB_DBT_USERMEM | DB_DBT_PARTIAL); if (db->get (NULL, &key, &value, 0) != 0) - return -EINVAL; // XXX how to say "badly formed fs?" + { + dout(4) << "..get superblock fails" << endl; + return -EINVAL; // XXX how to say "badly formed fs?" + } - dout(2) << ".mount " << super << endl; + dout(3) << ".mount " << super << endl; if (super.version != OSBDB_THIS_VERSION) - return -EINVAL; + { + dout(4) << "version mismatch (" << super.version << ")" << endl; + return -EINVAL; + } DBTYPE t; db->get_type (&t); @@ -164,7 +176,7 @@ int OSBDB::mount() db->get_flags (&flags); dout(1) << "mounted version " << OSBDB_THIS_VERSION << "; Btree; " << "min keys per page: " << minkey << "; flags: " - << hex << flags << endl; + << hex << flags << dec << endl; cout << dec; } else @@ -178,11 +190,12 @@ int OSBDB::mount() dout(1) << "mounted version " << OSBDB_THIS_VERSION << "; Hash; " << "fill factor: " << ffactor << " table size: " << nelem << "; flags: " - << hex << flags << endl; + << hex << flags << dec << endl; cout << dec; } mounted = true; + dout(4) << "..mounted" << endl; return 0; } @@ -224,6 +237,7 @@ int OSBDB::umount() } mounted = false; opened = false; + dout(4) << "..unmounted" << endl; return 0; } @@ -268,7 +282,7 @@ int OSBDB::mkfs() return -EIO; } dout(3) << "..wrote superblock" << endl; - + dout(4) << "..mkfs done" << endl; return 0; } @@ -277,6 +291,7 @@ int OSBDB::mkfs() int OSBDB::pick_object_revision_lt(object_t& oid) { // Not really needed. + dout(0) << "pick_object_revision_lt " << oid << endl; return -ENOSYS; } @@ -284,22 +299,32 @@ bool OSBDB::exists(object_t oid) { dout(2) << "exists " << oid << endl; struct stat st; - return (stat (oid, &st) == 0); + bool ret = (stat (oid, &st) == 0); + dout(4) << "..returns " << ret << endl; + return ret; } int OSBDB::statfs (struct statfs *st) { // Hacky? if (::statfs (device.c_str(), st) != 0) - return -errno; + { + int ret = -errno; + derr(1) << "statfs returns " << ret << endl; + return ret; + } st->f_type = OSBDB_MAGIC; + dout(4) << "..statfs OK" << endl; return 0; } int OSBDB::stat(object_t oid, struct stat *st) { if (!mounted) - return -EINVAL; + { + dout(4) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "stat " << oid << endl; @@ -320,13 +345,17 @@ int OSBDB::stat(object_t oid, struct stat *st) st->st_size = obj.length; dout(3) << "stat length:" << obj.length << endl; + dout(4) << "..stat OK" << endl; return 0; } int OSBDB::remove(object_t oid, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "remove " << oid << endl; @@ -338,6 +367,7 @@ int OSBDB::remove(object_t oid, Context *onsafe) mkoid(id, oid); Dbt key (&id, sizeof (oid_t)); db->del (NULL, &key, 0); + object_inode_key _ikey = new_object_inode_key (oid); Dbt ikey (&_ikey, sizeof_object_inode_key()); db->del (txn, &ikey, 0); @@ -360,20 +390,29 @@ int OSBDB::remove(object_t oid, Context *onsafe) db->del (txn, &askey, 0); } + // XXX check del return value + if (txn) txn->commit (0); + dout(4) << "..remove OK" << endl; return 0; } int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "truncate " << size << endl; if (size > 0xFFFFFFFF) - return -ENOSPC; + { + derr(1) << "object size too big!" << endl; + return -ENOSPC; + } DbTxn *txn = NULL; @@ -392,6 +431,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + dout(4) << "..returns -ENOENT" << endl; return -ENOENT; } @@ -410,6 +450,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".updating object failed" << endl; return -EIO; } @@ -419,6 +460,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".updating object info failed" << endl; return -EIO; } } @@ -432,6 +474,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".updating object info failed" << endl; return -EIO; } if (size == 0) @@ -445,6 +488,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".updating object failed" << endl; return -EIO; } } @@ -459,6 +503,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".getting old object failed" << endl; return -EIO; } auto_ptr ovalPtr ((char *) oval.get_data()); @@ -468,6 +513,7 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); + derr(1) << ".putting new object failed" << endl; return -EIO; } } @@ -476,13 +522,17 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) if (txn) txn->commit (0); + dout(4) << "..truncate OK" << endl; return 0; } int OSBDB::read(object_t oid, off_t offset, size_t len, bufferlist& bl) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "read " << oid << " " << offset << " " << len << endl; @@ -530,7 +580,10 @@ int OSBDB::read(object_t oid, off_t offset, size_t len, bufferlist& bl) else { if (offset > obj.length) - return 0; + { + dout(2) << "..offset out of range" << endl; + return 0; + } if (offset + len > obj.length) len = obj.length - (size_t) offset; dout(3) << " doing partial read of " << len << endl; @@ -554,6 +607,7 @@ int OSBDB::read(object_t oid, off_t offset, size_t len, bufferlist& bl) if (txn) txn->commit (0); + dout(4) << "..read OK, returning " << len << endl; return len; } @@ -561,13 +615,19 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, bufferlist& bl, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "write " << oid << " " << offset << " " << len << endl; if (offset > 0xFFFFFFFFL || offset + len > 0xFFFFFFFFL) - return -ENOSPC; + { + derr(1) << "object too big" << endl; + return -ENOSPC; + } DbTxn *txn = NULL; if (transactional) @@ -581,18 +641,18 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, ival.set_flags (DB_DBT_USERMEM); int ret; - dout(3) << " getting " << _ikey << endl; + dout(3) << "..getting " << _ikey << endl; if (db->get (txn, &ikey, &ival, 0) != 0) { - dout(3) << " writing new object" << endl; + dout(3) << "..writing new object" << endl; // New object. obj.length = (size_t) offset + len; - dout(3) << " mapping " << _ikey << " => " + dout(3) << "..mapping " << _ikey << " => " << obj << endl; if ((ret = db->put (txn, &ikey, &ival, 0)) != 0) { - derr(1) << " put returned " << db_strerror (ret) << endl; + derr(1) << "..put returned " << db_strerror (ret) << endl; if (txn) txn->abort(); return -EIO; @@ -614,11 +674,11 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, value.set_doff ((size_t) offset); value.set_dlen (len); } - dout(3) << " mapping " << oid << " => (" + dout(3) << "..mapping " << oid << " => (" << obj.length << " bytes)" << endl; if ((ret = db->put (txn, &key, &value, 0)) != 0) { - derr(1) << " put returned " << db_strerror (ret) << endl; + derr(1) << "..put returned " << db_strerror (ret) << endl; if (txn) txn->abort(); return -EIO; @@ -626,6 +686,8 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, if (txn) txn->commit (0); + + dout(4) << "..write OK, returning " << len << endl; return len; } @@ -650,6 +712,7 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, { if (txn) txn->abort(); + derr(1) << "..writing object failed!" << endl; return -EIO; } } @@ -662,6 +725,7 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, { if (txn) txn->abort(); + derr(1) << "..writing object info failed!" << endl; return -EIO; } } @@ -677,24 +741,33 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, { if (txn) txn->abort(); + derr(1) << "..writing object failed!" << endl; return -EIO; } } if (txn) txn->commit (0); + + dout(4) << "..write OK, returning " << len << endl; return len; } int OSBDB::clone(object_t oid, object_t noid) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "clone " << oid << ", " << noid << endl; if (exists (noid)) - return -EEXIST; + { + dout(4) << "..target exists; returning -EEXIST" << endl; + return -EEXIST; + } DbTxn *txn = NULL; if (transactional) @@ -721,12 +794,14 @@ int OSBDB::clone(object_t oid, object_t noid) { if (txn) txn->abort(); + derr(1) << "..getting object info failed!" << endl; return -ENOENT; } if (db->get (txn, &key, &value, 0) != 0) { if (txn) txn->abort(); + derr(1) << "..getting original object failed" << endl; return -ENOENT; } auto_ptr valueptr ((char *) value.get_data()); @@ -735,17 +810,21 @@ int OSBDB::clone(object_t oid, object_t noid) { if (txn) txn->abort(); + derr(1) << "..putting object info failed" << endl; return -EIO; } if (db->put (txn, &nkey, &value, 0) != 0) { if (txn) txn->abort(); + derr(1) << "..putting new object failed" << endl; return -EIO; } if (txn) txn->commit (0); + + dout(4) << "..clone OK" << endl; return 0; } @@ -754,7 +833,10 @@ int OSBDB::clone(object_t oid, object_t noid) int OSBDB::list_collections(list& ls) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted!" << endl; + return -EINVAL; + } dout(2) << "list_collections" << endl; @@ -763,22 +845,29 @@ int OSBDB::list_collections(list& ls) value.set_flags (DB_DBT_MALLOC); if (db->get (NULL, &key, &value, 0) != 0) - return 0; // no collections. + { + dout(4) << "..no collections" << endl; + return 0; // no collections. + } auto_ptr sc ((stored_colls *) value.get_data()); stored_colls *scp = sc.get(); for (uint32_t i = 0; i < sc->count; i++) ls.push_back (scp->colls[i]); + dout(4) << "..list_collections returns " << scp->count << endl; return scp->count; } int OSBDB::create_collection(coll_t c, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } - dout(2) << "create_collection " << c << endl; + dout(2) << "create_collection " << hex << c << dec << endl; Dbt key (COLLECTIONS_KEY, 1); Dbt value; @@ -812,6 +901,7 @@ int OSBDB::create_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".collection " << c << " already exists " << endl; return -EEXIST; } @@ -846,6 +936,7 @@ int OSBDB::create_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".writing new collections list failed" << endl; return -EIO; } } @@ -860,21 +951,27 @@ int OSBDB::create_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".writing new collection failed" << endl; return -EIO; } } if (txn != NULL) txn->commit (0); + + dout(4) << "..create_collection OK" << endl; return 0; } int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } - dout(2) << "destroy_collection " << c << endl; + dout(2) << "destroy_collection " << hex << c << dec << endl; Dbt key (COLLECTIONS_KEY, 1); Dbt value; @@ -888,6 +985,7 @@ int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".collection list doesn't exist" << endl; return -ENOENT; // XXX } @@ -897,23 +995,31 @@ int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".collection " << c << " not listed" << endl; return -ENOENT; } uint32_t ins = binary_search (scp->colls, scp->count, c); + dout(4) << "..insertion point is " << ins << endl; if (scp->colls[ins] != c) { if (txn != NULL) txn->abort(); + derr(1) << ".collection " << c << " not listed" << endl; return -ENOENT; } + dout(4) << "..collections list is " << scp << endl; + // Move the rest of the list down in memory, if needed. - if (ins < scp->count - 1) + if (ins < scp->count) { size_t n = scp->count - ins - 1; + dout(4) << "..shift list down " << n << endl; memmove (&scp->colls[ins], &scp->colls[ins + 1], n); } + dout(4) << "..collections list is " << scp << endl; + // Modify the record size to be one less. Dbt nvalue (scp, value.get_size() - sizeof (coll_t)); nvalue.set_flags (DB_DBT_USERMEM); @@ -921,6 +1027,7 @@ int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".putting modified collection list failed" << endl; return -EIO; } @@ -930,41 +1037,72 @@ int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << ".deleting collection failed" << endl; return -EIO; } if (txn != NULL) txn->commit (0); + dout(4) << "..destroy_collection OK" << endl; return 0; } bool OSBDB::collection_exists(coll_t c) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } - dout(2) << "collection_exists " << c << endl; + dout(2) << "collection_exists " << hex << c << dec << endl; - Dbt key (COLLECTIONS_KEY, 1); + /*Dbt key (COLLECTIONS_KEY, 1); Dbt value; value.set_flags (DB_DBT_MALLOC); if (db->get (NULL, &key, &value, 0) != 0) - return false; + { + dout(4) << "..no collection list; return false" << endl; + return false; + } stored_colls *scp = (stored_colls *) value.get_data(); auto_ptr sc (scp); + dout(5) << "..collection list is " << scp << endl; if (scp->count == 0) - return false; + { + dout(4) << "..empty collection list; return false" << endl; + return false; + } uint32_t ins = binary_search (scp->colls, scp->count, c); + dout(4) << "..insertion point is " << ins << endl; + + int ret = (scp->colls[ins] == c); + dout(4) << "..returns " << ret << endl; + return ret;*/ - return (scp->colls[ins] == c); + Dbt key (&c, sizeof (coll_t)); + Dbt value; + value.set_flags (DB_DBT_MALLOC); + if (db->get (NULL, &key, &value, 0) != 0) + { + dout(4) << "..no collection, return false" << endl; + return false; + } + void *val = value.get_data(); + free (val); + dout(4) << "..collection exists; return true" << endl; + return true; } int OSBDB::collection_stat(coll_t c, struct stat *st) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } dout(2) << "collection_stat " << c << endl; // XXX is this needed? @@ -974,9 +1112,12 @@ int OSBDB::collection_stat(coll_t c, struct stat *st) int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) { if (!mounted) - return -EINVAL; + { + dout(2) << "not mounted" << endl; + return -EINVAL; + } - dout(2) << "collection_add " << c << " " << o << endl; + dout(2) << "collection_add " << hex << c << dec << " " << o << endl; Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -990,6 +1131,7 @@ int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << "failed to find collection" << endl; return -ENOENT; } @@ -1007,6 +1149,7 @@ int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << "collection already has object" << endl; return -EEXIST; } } @@ -1016,9 +1159,11 @@ int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) scp = (stored_coll *) realloc (scp, sz); sc.release(); sc.reset (scp); - if (ins < scp->count) + dout(3) << "..current collection: " << scp << endl; + if (ins < scp->count - 1) { size_t n = (scp->count - ins) * sizeof (object_t); + dout(3) << "..move up " << n << " bytes" << endl; memmove (&scp->objects[ins + 1], &scp->objects[ins], n); } scp->count++; @@ -1031,20 +1176,25 @@ int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << "..putting modified collection failed" << endl; return -EIO; } if (txn != NULL) txn->commit (0); + dout(4) << "..collection add OK" << endl; return 0; } int OSBDB::collection_remove(coll_t c, object_t o, Context *onsafe) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } - dout(2) << "collection_remove " << c << " " << o << endl; + dout(2) << "collection_remove " << hex << c << dec << " " << o << endl; Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -1058,29 +1208,35 @@ int OSBDB::collection_remove(coll_t c, object_t o, Context *onsafe) { if (txn != NULL) txn->abort(); + dout(1) << "..collection doesn't exist" << endl; return -ENOENT; } stored_coll *scp = (stored_coll *) value.get_data(); auto_ptr sc (scp); + dout(5) << "..collection is " << scp << endl; if (scp->count == 0) { if (txn != NULL) txn->abort(); + dout(1) << "..collection is empty" << endl; return -ENOENT; } uint32_t ins = binary_search (scp->objects, scp->count, o); + dout(4) << "..insertion point is " << ins << endl; if (scp->objects[ins] != o) { if (txn != NULL) txn->abort(); + dout(1) << "..object not in collection" << endl; return -ENOENT; } if (ins < scp->count - 1) { size_t n = (scp->count - ins - 1) * sizeof (object_t); + dout(5) << "..moving " << n << " bytes down" << endl; memmove (&scp->objects[ins], &scp->objects[ins + 1], n); } scp->count--; @@ -1092,18 +1248,23 @@ int OSBDB::collection_remove(coll_t c, object_t o, Context *onsafe) { if (txn != NULL) txn->abort(); + derr(1) << "..putting modified collection failed" << endl; return -EIO; } if (txn != NULL) txn->commit (0); + dout(4) << "..collection remove OK" << endl; return 0; } int OSBDB::collection_list(coll_t c, list& o) { if (!mounted) - return -EINVAL; + { + derr(1) << "not mounted" << endl; + return -EINVAL; + } Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -1161,7 +1322,7 @@ int OSBDB::_setattr(object_t oid, const char *name, { sz = attrs_val.get_size(); sap = (stored_attrs *) attrs_val.get_data(); - dout(2) << " add to list of " << sap->count << " attrs" << endl; + dout(2) << "..add to list of " << sap->count << " attrs" << endl; } auto_ptr sa (sap); @@ -1171,22 +1332,22 @@ int OSBDB::_setattr(object_t oid, const char *name, int ins = 0; if (sap->count > 0) ins = binary_search (sap->names, sap->count, _name); - dout(3) << " insertion point is " << ins << endl; + dout(3) << "..insertion point is " << ins << endl; if (sap->count == 0 || strcmp (sap->names[ins].name, name) != 0) { sz += sizeof (attr_name); - dout(3) << " realloc 0x" << hex << ((void *) sap) << " to " + dout(3) << "..realloc " << ((void *) sap) << " to " << dec << sz << endl; sap = (stored_attrs *) realloc (sap, sz); - dout(3) << " returns 0x" << hex << ((void *) sap) << endl; + dout(3) << "..returns " << ((void *) sap) << endl; sa.release (); sa.reset (sap); int n = (sap->count - ins) * sizeof (attr_name); if (n > 0) { - dout(3) << " move " << n << " bytes from 0x" + dout(3) << "..move " << n << " bytes from 0x" << hex << (&sap->names[ins]) << " to 0x" - << hex << (&sap->names[ins+1]) << endl; + << hex << (&sap->names[ins+1]) << dec << endl; memmove (&sap->names[ins+1], &sap->names[ins], n); } memset (&sap->names[ins], 0, sizeof (attr_name)); @@ -1196,25 +1357,32 @@ int OSBDB::_setattr(object_t oid, const char *name, Dbt newAttrs_val (sap, sz); newAttrs_val.set_ulen (sz); newAttrs_val.set_flags (DB_DBT_USERMEM); - dout(3) << " putting " << aids << endl; + dout(3) << "..putting " << aids << endl; if (db->put (txn, &attrs_key, &newAttrs_val, 0) != 0) - return -EIO; + { + derr(1) << ".writing attributes list failed" << endl; + return -EIO; + } } else { - dout(3) << " attribute " << name << " already exists" << endl; + dout(3) << "..attribute " << name << " already exists" << endl; } - dout(3) << " attributes list: " << sap << endl; + dout(5) << "..attributes list: " << sap << endl; // Add the attribute. attr_id aid = new_attr_id (oid, name); Dbt attr_key (&aid, sizeof (aid)); Dbt attr_val ((void *) value, size); - dout(3) << " writing attribute key " << aid << endl; + dout(3) << "..writing attribute key " << aid << endl; if (db->put (txn, &attr_key, &attr_val, 0) != 0) - return -EIO; + { + derr(1) << ".writing attribute key failed" << endl; + return -EIO; + } + dout(4) << "..setattr OK" << endl; return 0; } @@ -1281,17 +1449,23 @@ int OSBDB::_getattr (object_t oid, const char *name, void *value, size_t size) if (!mounted) return -EINVAL; + dout(2) << "_getattr " << oid << " " << name << " " << size << endl; + attr_id aid = new_attr_id (oid, name); Dbt key (&aid, sizeof (aid)); Dbt val (value, size); val.set_ulen (size); + val.set_doff (0); + val.set_dlen (size); val.set_flags (DB_DBT_USERMEM | DB_DBT_PARTIAL); if (db->get (NULL, &key, &val, 0) != 0) { + derr(1) << ".getting value failed" << endl; return -ENOENT; } + dout(4) << ".._getattr OK; returns " << val.get_size() << endl; return val.get_size(); } @@ -1308,7 +1482,6 @@ int OSBDB::getattrs(object_t oid, map& aset) if (!mounted) return -EINVAL; - int count = 0; for (map::iterator it = aset.begin(); it != aset.end(); it++) { @@ -1317,15 +1490,17 @@ int OSBDB::getattrs(object_t oid, map& aset) (*it).second.length()); if (ret < 0) return ret; - count += ret; } - return count; + return 0; } int OSBDB::rmattr(object_t oid, const char *name, Context *onsafe) { if (!mounted) return -EINVAL; + + dout(2) << "rmattr " << oid << " " << name << endl; + attrs_id aids = new_attrs_id (oid); Dbt askey (&aids, sizeof_attrs_id()); Dbt asvalue; @@ -1346,29 +1521,39 @@ int OSBDB::rmattr(object_t oid, const char *name, Context *onsafe) stored_attrs *sap = (stored_attrs *) asvalue.get_data(); auto_ptr sa (sap); + dout(5) << "..attributes list " << sap << endl; + if (sap->count == 0) { if (txn != NULL) txn->abort(); + derr(1) << ".empty attribute list" << endl; return -ENOENT; } attr_name _name; - memset(&name, 0, sizeof (_name)); + memset(&_name, 0, sizeof (_name)); strncpy (_name.name, name, OSBDB_MAX_ATTR_LEN); int ins = binary_search (sap->names, sap->count, _name); + dout(4) << "..insertion point is " << ins << endl; if (strcmp (sap->names[ins].name, name) != 0) { if (txn != NULL) txn->abort(); + derr(1) << ".attribute not found in list" << endl; return -ENOENT; } // Shift the later elements down by one, if needed. int n = (sap->count - ins) * sizeof (attr_name); if (n > 0) - memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); + { + dout(4) << "..shift down by " << n << endl; + memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); + } sap->count--; + dout(5) << "..attributes list now " << sap << endl; + asvalue.set_size(asvalue.get_size() - sizeof (attr_name)); int ret; if ((ret = db->put (txn, &askey, &asvalue, 0)) != 0) @@ -1392,6 +1577,7 @@ int OSBDB::rmattr(object_t oid, const char *name, Context *onsafe) if (txn != NULL) txn->commit (0); + dout(4) << "..rmattr OK" << endl; return 0; } @@ -1429,6 +1615,8 @@ int OSBDB::listattr(object_t oid, char *attrs, size_t size) p[n] = '\0'; p = p + n + 1; } + + dout(4) << "listattr OK" << endl; return 0; } @@ -1441,10 +1629,13 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, if (!mounted) return -EINVAL; - dout(2) << "collection_setattr" << cid << " " << name + dout(2) << "collection_setattr " << hex << cid << dec << " " << name << " (" << size << " bytes)" << endl; if (strlen (name) >= OSBDB_MAX_ATTR_LEN) - return -ENAMETOOLONG; + { + derr(1) << "name too long" << endl; + return -ENAMETOOLONG; + } // Add name to attribute list, if needed. coll_attrs_id aids = new_coll_attrs_id (cid); @@ -1484,10 +1675,10 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, if (sap->count == 0 || strcmp (sap->names[ins].name, name) != 0) { sz += sizeof (attr_name); - dout(3) << " realloc 0x" << hex << ((void *) sap) << " to " + dout(3) << " realloc " << hex << ((void *) sap) << " to " << dec << sz << endl; sap = (stored_attrs *) realloc (sap, sz); - dout(3) << " returns 0x" << hex << ((void *) sap) << endl; + dout(3) << " returns " << hex << ((void *) sap) << dec << endl; sa.release (); sa.reset (sap); int n = (sap->count - ins) * sizeof (attr_name); @@ -1495,7 +1686,7 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, { dout(3) << " move " << n << " bytes from 0x" << hex << (&sap->names[ins]) << " to 0x" - << hex << (&sap->names[ins+1]) << endl; + << hex << (&sap->names[ins+1]) << dec << endl; memmove (&sap->names[ins+1], &sap->names[ins], n); } memset (&sap->names[ins], 0, sizeof (attr_name)); @@ -1510,15 +1701,16 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, { if (txn != NULL) txn->abort(); + derr(1) << ".putting new attributes failed" << endl; return -EIO; } } else { - dout(3) << " attribute " << name << " already exists" << endl; + dout(3) << "..attribute " << name << " already exists" << endl; } - dout(3) << " attributes list: " << sap << endl; + dout(3) << "..attributes list: " << sap << endl; // Add the attribute. coll_attr_id aid = new_coll_attr_id (cid, name); @@ -1529,11 +1721,14 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, { if (txn != NULL) txn->abort(); + derr(1) << ".putting attribute failed" << endl; return -EIO; } if (txn != NULL) txn->commit (0); + + dout(4) << "..collection setattr OK" << endl; return 0; } @@ -1543,6 +1738,9 @@ int OSBDB::collection_rmattr(coll_t cid, const char *name, if (!mounted) return -EINVAL; + dout(2) << "collection_rmattr " << hex << cid << dec + << " " << name << endl; + coll_attrs_id aids = new_coll_attrs_id (cid); Dbt askey (&aids, sizeof_coll_attrs_id()); Dbt asvalue; @@ -1556,35 +1754,44 @@ int OSBDB::collection_rmattr(coll_t cid, const char *name, { if (txn != NULL) txn->abort(); + derr(1) << ".no attributes list" << endl; return -ENOENT; } stored_attrs *sap = (stored_attrs *) asvalue.get_data(); auto_ptr sa (sap); + dout(5) << "..attributes list " << sap << endl; if (sap->count == 0) { if (txn != NULL) txn->abort(); + derr(1) << ".empty attributes list" << endl; return -ENOENT; } attr_name _name; - memset(&name, 0, sizeof (_name)); + memset(&_name, 0, sizeof (_name)); strncpy (_name.name, name, OSBDB_MAX_ATTR_LEN); int ins = binary_search (sap->names, sap->count, _name); if (strcmp (sap->names[ins].name, name) != 0) { if (txn != NULL) txn->abort(); + derr(1) << ".attribute not listed" << endl; return -ENOENT; } // Shift the later elements down by one, if needed. int n = (sap->count - ins) * sizeof (attr_name); if (n > 0) - memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); + { + dout(4) << "..shift down by " << n << endl; + memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); + } sap->count--; + dout(5) << "..attributes list now " << sap << endl; + asvalue.set_size(asvalue.get_size() - sizeof (attr_name)); int ret; if ((ret = db->put (txn, &askey, &asvalue, 0)) != 0) @@ -1608,6 +1815,8 @@ int OSBDB::collection_rmattr(coll_t cid, const char *name, if (txn != NULL) txn->commit (0); + + dout(4) << "..collection rmattr OK" << endl; return 0; } @@ -1617,7 +1826,8 @@ int OSBDB::collection_getattr(coll_t cid, const char *name, if (!mounted) return -EINVAL; - dout(2) << "collection_getattr " << cid << " " << name << endl; + dout(2) << "collection_getattr " << hex << cid << dec + << " " << name << endl; // XXX transactions/read isolation? @@ -1629,8 +1839,12 @@ int OSBDB::collection_getattr(coll_t cid, const char *name, val.set_flags (DB_DBT_USERMEM | DB_DBT_PARTIAL); if (db->get (NULL, &key, &val, 0) != 0) - return -ENOENT; + { + derr(1) << ".no attribute entry" << endl; + return -ENOENT; + } + dout(4) << "..collection getattr OK; returns " << val.get_size() << endl; return val.get_size(); } @@ -1639,7 +1853,7 @@ int OSBDB::collection_listattr(coll_t cid, char *attrs, size_t size) if (!mounted) return -EINVAL; - dout(2) << "collection_listattr " << cid << endl; + dout(2) << "collection_listattr " << hex << cid << dec << endl; // XXX transactions/read isolation? diff --git a/branches/sage/cephmds2/osd/OSD.cc b/branches/sage/cephmds2/osd/OSD.cc index 4404822fb5e14..058692fab3fc0 100644 --- a/branches/sage/cephmds2/osd/OSD.cc +++ b/branches/sage/cephmds2/osd/OSD.cc @@ -739,8 +739,9 @@ void OSD::ms_handle_failure(Message *m, const entity_inst_t& inst) if (dest.is_osd()) { // failed osd. drop message, report to mon. int mon = monmap->pick_mon(); - dout(0) << "ms_handle_failure " << dest << " inst " << inst + dout(0) << "ms_handle_failure " << inst << ", dropping and reporting to mon" << mon + << " " << *m << endl; messenger->send_message(new MOSDFailure(inst, osdmap->get_epoch()), monmap->get_inst(mon)); @@ -748,15 +749,16 @@ void OSD::ms_handle_failure(Message *m, const entity_inst_t& inst) } else if (dest.is_mon()) { // resend to a different monitor. int mon = monmap->pick_mon(true); - dout(0) << "ms_handle_failure " << dest << " inst " << inst + dout(0) << "ms_handle_failure " << inst << ", resending to mon" << mon + << " " << *m << endl; messenger->send_message(m, monmap->get_inst(mon)); } else { // client? - dout(0) << "ms_handle_failure " << dest << " inst " << inst - << ", dropping" << endl; + dout(0) << "ms_handle_failure " << inst + << ", dropping " << *m << endl; delete m; } } @@ -3435,7 +3437,7 @@ void OSD::prepare_op_transaction(ObjectStore::Transaction& t, struct stat st; int r = store->stat(oid, &st); if (r >= 0) { - if (op->get_offset() + op->get_length() >= st.st_size) { + if (op->get_offset() + (off_t)op->get_length() >= (off_t)st.st_size) { if (op->get_offset()) t.truncate(oid, op->get_length() + op->get_offset()); else diff --git a/branches/sage/cephmds2/osdc/Journaler.cc b/branches/sage/cephmds2/osdc/Journaler.cc index c77c7e7d0abd4..dee6448b3494d 100644 --- a/branches/sage/cephmds2/osdc/Journaler.cc +++ b/branches/sage/cephmds2/osdc/Journaler.cc @@ -239,7 +239,7 @@ off_t Journaler::append_entry(bufferlist& bl, Context *onsync) if (!g_conf.journaler_allow_split_entries) { // will we span a stripe boundary? int p = inode.layout.stripe_size; - if (write_pos / p != (write_pos + bl.length() + sizeof(s)) / p) { + if (write_pos / p != (write_pos + (off_t)(bl.length() + sizeof(s))) / p) { // yes. // move write_pos forward. off_t owp = write_pos; @@ -498,7 +498,7 @@ bool Journaler::is_readable() // start reading some more? if (!_is_reading()) { if (s) - fetch_len = MAX(fetch_len, sizeof(s)+s-read_buf.length()); + fetch_len = MAX(fetch_len, (off_t)(sizeof(s)+s-read_buf.length())); _issue_read(fetch_len); } diff --git a/branches/sage/cephmds2/osdc/ObjectCacher.cc b/branches/sage/cephmds2/osdc/ObjectCacher.cc index cb8db645f49e7..0933675ae2880 100644 --- a/branches/sage/cephmds2/osdc/ObjectCacher.cc +++ b/branches/sage/cephmds2/osdc/ObjectCacher.cc @@ -96,50 +96,7 @@ void ObjectCacher::Object::merge_left(BufferHead *left, BufferHead *right) dout(10) << "merge_left result " << *left << endl; } -/* buggy possibly, but more importnatly, unnecessary. -void ObjectCacher::Object::merge_right(BufferHead *left, BufferHead *right) -{ - assert(left->end() == right->start()); - assert(left->get_state() == right->get_state()); - - dout(10) << "merge_right " << *left << " + " << *right << endl; - oc->bh_remove(this, left); - oc->bh_stat_sub(right); - data.erase(right->start()); - right->set_start( left->start() ); - data[right->start()] = right; - right->set_length( left->length() + right->length()); - oc->bh_stat_add(right); - - // data - bufferlist nbl; - nbl.claim(left->bl); - nbl.claim_append(right->bl); - right->bl.claim(nbl); - - // version - // note: this is sorta busted, but should only be used for dirty buffers - right->last_write_tid = MAX( left->last_write_tid, right->last_write_tid ); - - // waiters - map > old; - old.swap(right->waitfor_read); - // take left's waiters - right->waitfor_read.swap(left->waitfor_read); - - // shift old waiters - for (map >::iterator p = old.begin(); - p != old.end(); - p++) - right->waitfor_read[p->first + left->length()].swap( p->second ); - - // hose left - delete left; - - dout(10) << "merge_right result " << *right << endl; -} -*/ /* * map a range of bytes into buffer_heads. @@ -374,8 +331,25 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr #define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_objectcacher) cout << g_clock.now() << " " << objecter->messenger->get_myname() << ".objectcacher " + /* private */ +void ObjectCacher::close_object(Object *ob) +{ + dout(10) << "close_object " << *ob << endl; + assert(ob->can_close()); + + // ok! + objects.erase(ob->get_oid()); + objects_by_ino[ob->get_ino()].erase(ob); + if (objects_by_ino[ob->get_ino()].empty()) + objects_by_ino.erase(ob->get_ino()); + delete ob; +} + + + + void ObjectCacher::bh_read(BufferHead *bh) { dout(7) << "bh_read on " << *bh << endl; @@ -817,6 +791,9 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish) } dout(10) << "readx result is " << rd->bl->length() << endl; + // done with read. + delete rd; + trim(); return pos; @@ -1258,6 +1235,26 @@ bool ObjectCacher::set_is_dirty_or_committing(inodeno_t ino) } +// purge. non-blocking. violently removes dirty buffers from cache. +void ObjectCacher::purge(Object *ob) +{ + dout(10) << "purge " << *ob << endl; + + for (map::iterator p = ob->data.begin(); + p != ob->data.end(); + p++) { + BufferHead *bh = p->second; + dout(0) << "purge forcibly removing " << *bh << endl; + bh_remove(ob, bh); + delete bh; + } + + if (ob->can_close()) { + dout(10) << "trim trimming " << *ob << endl; + close_object(ob); + } +} + // flush. non-blocking. no callback. // true if clean, already flushed. // false if we wrote something. @@ -1366,6 +1363,24 @@ bool ObjectCacher::commit_set(inodeno_t ino, Context *onfinish) return false; } +void ObjectCacher::purge_set(inodeno_t ino) +{ + if (objects_by_ino.count(ino) == 0) { + dout(10) << "purge_set on " << ino << " dne" << endl; + return; + } + + dout(10) << "purge_set " << ino << endl; + + set& s = objects_by_ino[ino]; + for (set::iterator i = s.begin(); + i != s.end(); + i++) { + Object *ob = *i; + purge(ob); + } +} + off_t ObjectCacher::release(Object *ob) { @@ -1384,8 +1399,15 @@ off_t ObjectCacher::release(Object *ob) for (list::iterator p = clean.begin(); p != clean.end(); - p++) + p++) { bh_remove(ob, *p); + delete *p; + } + + if (ob->can_close()) { + dout(10) << "trim trimming " << *ob << endl; + close_object(ob); + } return o_unclean; } @@ -1402,7 +1424,7 @@ off_t ObjectCacher::release_set(inodeno_t ino) dout(10) << "release_set " << ino << endl; - set& s = objects_by_ino[ino]; + set s = objects_by_ino[ino]; for (set::iterator i = s.begin(); i != s.end(); i++) { diff --git a/branches/sage/cephmds2/osdc/ObjectCacher.h b/branches/sage/cephmds2/osdc/ObjectCacher.h index 27b154023209d..e9a4041008666 100644 --- a/branches/sage/cephmds2/osdc/ObjectCacher.h +++ b/branches/sage/cephmds2/osdc/ObjectCacher.h @@ -133,6 +133,9 @@ class ObjectCacher { last_write_tid(0), last_ack_tid(0), last_commit_tid(0), lock_state(LOCK_NONE), wrlock_ref(0), rdlock_ref(0) {} + ~Object() { + assert(data.empty()); + } object_t get_oid() { return oid; } inodeno_t get_ino() { return ino; } @@ -227,16 +230,7 @@ class ObjectCacher { objects_by_ino[ino].insert(o); return o; } - void close_object(Object *ob) { - assert(ob->can_close()); - - // ok! - objects.erase(ob->get_oid()); - objects_by_ino[ob->get_ino()].erase(ob); - if (objects_by_ino[ob->get_ino()].empty()) - objects_by_ino.erase(ob->get_ino()); - delete ob; - } + void close_object(Object *ob); // bh stats Cond stat_cond; @@ -315,18 +309,22 @@ class ObjectCacher { void bh_add(Object *ob, BufferHead *bh) { ob->add_bh(bh); - if (bh->is_dirty()) + if (bh->is_dirty()) { lru_dirty.lru_insert_top(bh); - else + dirty_bh.insert(bh); + } else { lru_rest.lru_insert_top(bh); + } bh_stat_add(bh); } void bh_remove(Object *ob, BufferHead *bh) { ob->remove_bh(bh); - if (bh->is_dirty()) + if (bh->is_dirty()) { lru_dirty.lru_remove(bh); - else + dirty_bh.erase(bh); + } else { lru_rest.lru_remove(bh); + } bh_stat_sub(bh); } @@ -339,6 +337,7 @@ class ObjectCacher { bool flush(Object *o); off_t release(Object *o); + void purge(Object *o); void rdlock(Object *o); void rdunlock(Object *o); @@ -413,10 +412,17 @@ class ObjectCacher { flusher_thread.create(); } ~ObjectCacher() { - //lock.Lock(); // hmm.. watch out for deadlock! + // we should be empty. + assert(objects.empty()); + assert(lru_rest.lru_get_size() == 0); + assert(lru_dirty.lru_get_size() == 0); + assert(dirty_bh.empty()); + + assert(flusher_thread.is_started()); + lock.Lock(); // hmm.. watch out for deadlock! flusher_stop = true; flusher_cond.Signal(); - //lock.Unlock(); + lock.Unlock(); flusher_thread.join(); } @@ -457,6 +463,8 @@ class ObjectCacher { bool commit_set(inodeno_t ino, Context *oncommit); void commit_all(Context *oncommit=0); + void purge_set(inodeno_t ino); + off_t release_set(inodeno_t ino); // returns # of bytes not released (ie non-clean) void kick_sync_writers(inodeno_t ino); diff --git a/branches/sage/cephmds2/osdc/Objecter.cc b/branches/sage/cephmds2/osdc/Objecter.cc index ddd22325747db..9e49a43ace89b 100644 --- a/branches/sage/cephmds2/osdc/Objecter.cc +++ b/branches/sage/cephmds2/osdc/Objecter.cc @@ -269,27 +269,31 @@ tid_t Objecter::stat_submit(OSDStat *st) ObjectExtent &ex = st->extents.front(); PG &pg = get_pg( ex.pgid ); - // send + // pick tid last_tid++; assert(client_inc >= 0); - MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, last_tid, - ex.oid, ex.pgid, osdmap->get_epoch(), - OSD_OP_STAT); + + // add to gather set + st->tid = last_tid; + op_stat[last_tid] = st; + + pg.active_tids.insert(last_tid); + + // send? dout(10) << "stat_submit " << st << " tid " << last_tid << " oid " << ex.oid << " pg " << ex.pgid << " osd" << pg.acker() << endl; - if (pg.acker() >= 0) + if (pg.acker() >= 0) { + MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, last_tid, + ex.oid, ex.pgid, osdmap->get_epoch(), + OSD_OP_STAT); + messenger->send_message(m, osdmap->get_inst(pg.acker())); + } - // add to gather set - st->tid = last_tid; - op_stat[last_tid] = st; - - pg.active_tids.insert(last_tid); - return last_tid; } @@ -381,14 +385,17 @@ tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex) // find OSD PG &pg = get_pg( ex.pgid ); - // send + // pick tid last_tid++; assert(client_inc >= 0); - MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, last_tid, - ex.oid, ex.pgid, osdmap->get_epoch(), - OSD_OP_READ); - m->set_length(ex.length); - m->set_offset(ex.start); + + // add to gather set + rd->ops[last_tid] = ex; + op_read[last_tid] = rd; + + pg.active_tids.insert(last_tid); + + // send? dout(10) << "readx_submit " << rd << " tid " << last_tid << " oid " << ex.oid << " " << ex.start << "~" << ex.length << " (" << ex.buffer_extents.size() << " buffer fragments)" @@ -396,15 +403,16 @@ tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex) << " osd" << pg.acker() << endl; - if (pg.acker() >= 0) + if (pg.acker() >= 0) { + MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, last_tid, + ex.oid, ex.pgid, osdmap->get_epoch(), + OSD_OP_READ); + m->set_length(ex.length); + m->set_offset(ex.start); + messenger->send_message(m, osdmap->get_inst(pg.acker())); + } - // add to gather set - rd->ops[last_tid] = ex; - op_read[last_tid] = rd; - - pg.active_tids.insert(last_tid); - return last_tid; } @@ -641,43 +649,13 @@ tid_t Objecter::modifyx_submit(OSDModify *wr, ObjectExtent &ex, tid_t usetid) // find PG &pg = get_pg( ex.pgid ); - // send + // pick tid tid_t tid; if (usetid > 0) tid = usetid; else tid = ++last_tid; - MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, tid, - ex.oid, ex.pgid, osdmap->get_epoch(), - wr->op); - m->set_length(ex.length); - m->set_offset(ex.start); - m->set_rev(ex.rev); - - if (wr->tid_version.count(tid)) - m->set_version(wr->tid_version[tid]); // we're replaying this op! - - // what type of op? - switch (wr->op) { - case OSD_OP_WRITE: - { - // map buffer segments into this extent - // (may be fragmented bc of striping) - bufferlist cur; - for (map::iterator bit = ex.buffer_extents.begin(); - bit != ex.buffer_extents.end(); - bit++) { - bufferlist thisbit; - thisbit.substr_of(((OSDWrite*)wr)->bl, bit->first, bit->second); - cur.claim_append(thisbit); - } - assert(cur.length() == ex.length); - m->set_data(cur);//.claim(cur); - } - break; - } - // add to gather set wr->waitfor_ack[tid] = ex; wr->waitfor_commit[tid] = ex; @@ -687,15 +665,46 @@ tid_t Objecter::modifyx_submit(OSDModify *wr, ObjectExtent &ex, tid_t usetid) ++num_unacked; ++num_uncommitted; - // send + // send? dout(10) << "modifyx_submit " << MOSDOp::get_opname(wr->op) << " tid " << tid << " oid " << ex.oid << " " << ex.start << "~" << ex.length << " pg " << ex.pgid << " osd" << pg.primary() << endl; - if (pg.primary() >= 0) + if (pg.primary() >= 0) { + MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, tid, + ex.oid, ex.pgid, osdmap->get_epoch(), + wr->op); + m->set_length(ex.length); + m->set_offset(ex.start); + m->set_rev(ex.rev); + + if (wr->tid_version.count(tid)) + m->set_version(wr->tid_version[tid]); // we're replaying this op! + + // what type of op? + switch (wr->op) { + case OSD_OP_WRITE: + { + // map buffer segments into this extent + // (may be fragmented bc of striping) + bufferlist cur; + for (map::iterator bit = ex.buffer_extents.begin(); + bit != ex.buffer_extents.end(); + bit++) { + bufferlist thisbit; + thisbit.substr_of(((OSDWrite*)wr)->bl, bit->first, bit->second); + cur.claim_append(thisbit); + } + assert(cur.length() == ex.length); + m->set_data(cur);//.claim(cur); + } + break; + } + messenger->send_message(m, osdmap->get_inst(pg.primary())); + } dout(5) << num_unacked << " unacked, " << num_uncommitted << " uncommitted" << endl; diff --git a/branches/sage/cephmds2/script/runset.pl b/branches/sage/cephmds2/script/runset.pl index a1425862ceb42..966cf4e5100cb 100755 --- a/branches/sage/cephmds2/script/runset.pl +++ b/branches/sage/cephmds2/script/runset.pl @@ -197,7 +197,7 @@ sub run { #$e = './tcpsynobfs' if $h->{'fs'} eq 'obfs'; my $c = "$e"; $c .= " --mkfs" unless $h->{'no_mkfs'}; - $c .= " --$h->{'fs'}"; + $c .= " --$h->{'fs'}" if $h->{'fs'}; $c .= " --syn until $h->{'until'}" if $h->{'until'}; $c .= " --syn writefile $h->{'writefile_mb'} $h->{'writefile_size'}" if $h->{'writefile'}; diff --git a/branches/sage/cephmds2/test/testos.cc b/branches/sage/cephmds2/test/testos.cc index ee27a16ee4786..24c81590d899c 100644 --- a/branches/sage/cephmds2/test/testos.cc +++ b/branches/sage/cephmds2/test/testos.cc @@ -216,13 +216,14 @@ int main (int argc, char **argv) cerr << "write " << oids[o] << " failed: " << strerror (-ret) << endl; } + os->sync(); + utime_t end = g_clock.now() - begin; cerr << "Write finished in " << end << endl; total_write += end; writes[i] = end; - os->sync(); os->umount(); sync(); diff --git a/branches/sage/cephmds2/test/testosbdb.cc b/branches/sage/cephmds2/test/testosbdb.cc index 50a4ee663fcff..19268e7587531 100644 --- a/branches/sage/cephmds2/test/testosbdb.cc +++ b/branches/sage/cephmds2/test/testosbdb.cc @@ -14,7 +14,7 @@ main (int argc, char **argv) argv_to_vec (argc, argv, args); parse_config_options (args); - g_conf.debug_bdbstore = 3; + g_conf.debug_bdbstore = 10; //g_conf.bdbstore_btree = true; char dbfile[256]; strncpy (dbfile, "/tmp/testosbdb/db.XXXXXX", 256); @@ -123,6 +123,73 @@ main (int argc, char **argv) } } + char attrvalue[256]; + memset(attrvalue, 0, sizeof (attrvalue)); + if (os->getattr (oid, "alpha", attrvalue, sizeof(attrvalue)) < 0) + { + cout << "FAIL: getattr alpha" << endl; + } + else if (strncmp ("value", attrvalue, strlen("value")) != 0) + { + cout << "FAIL: read attribute value differs" << endl; + } + memset(attrvalue, 0, sizeof (attrvalue)); + if (os->getattr (oid, "fred", attrvalue, sizeof(attrvalue)) < 0) + { + cout << "FAIL: getattr fred" << endl; + } + else if (strncmp ("value", attrvalue, strlen("value")) != 0) + { + cout << "FAIL: read attribute value differs" << endl; + } + memset(attrvalue, 0, sizeof (attrvalue)); + if (os->getattr (oid, "beta", attrvalue, sizeof(attrvalue)) < 0) + { + cout << "FAIL: getattr beta" << endl; + } + else if (strncmp ("value", attrvalue, strlen("value")) != 0) + { + cout << "FAIL: read attribute value differs" << endl; + } + memset(attrvalue, 0, sizeof (attrvalue)); + if (os->getattr (oid, "gamma", attrvalue, sizeof(attrvalue)) < 0) + { + cout << "FAIL: getattr gamma" << endl; + } + else if (strncmp ("value", attrvalue, strlen("value")) != 0) + { + cout << "FAIL: read attribute value differs" << endl; + } + + if (os->setattr (oid, "alpha", "different", strlen("different")) != 0) + cout << "FAIL: setattr overwrite" << endl; + memset(attrvalue, 0, sizeof (attrvalue)); + if (os->getattr (oid, "alpha", attrvalue, sizeof(attrvalue)) < 0) + { + cout << "FAIL: getattr alpha" << endl; + } + else if (strncmp ("different", attrvalue, strlen("different")) != 0) + { + cout << "FAIL: read attribute value differs" << endl; + } + + if (os->rmattr (oid, "alpha") != 0) + { + cout << "FAIL: rmattr alpha" << endl; + } + if (os->rmattr (oid, "fred") != 0) + { + cout << "FAIL: rmattr fred" << endl; + } + if (os->rmattr (oid, "beta") != 0) + { + cout << "FAIL: rmattr beta" << endl; + } + if (os->rmattr (oid, "gamma") != 0) + { + cout << "FAIL: rmattr gamma" << endl; + } + coll_t cid = 0xCAFEBABE; if (os->create_collection (cid) != 0) { @@ -186,6 +253,71 @@ main (int argc, char **argv) oid2.rev--; } + if (os->collection_setattr (cid, "alpha", "value", 5) != 0) + cout << "FAIL: collection_setattr" << endl; + if (os->collection_setattr (cid, "beta", "value", 5) != 0) + cout << "FAIL: collection_setattr" << endl; + if (os->collection_setattr (cid, "gamma", "value", 5) != 0) + cout << "FAIL: collection_setattr" << endl; + if (os->collection_setattr (cid, "fred", "value", 5) != 0) + cout << "FAIL: collection_setattr" << endl; + + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "alpha", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "beta", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "gamma", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "fred", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + + if (os->collection_setattr (cid, "alpha", "eulavvalue", 10) != 0) + cout << "FAIL: collection setattr overwrite" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "alpha", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "eulavvalue", 10) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "beta", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "gamma", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + memset (attrvalue, 0, sizeof (attrvalue)); + if (os->collection_getattr (cid, "fred", attrvalue, sizeof (attrvalue)) < 0) + cout << "FAIL: collection_getattr" << endl; + else if (strncmp (attrvalue, "value", 5) != 0) + cout << "FAIL: collection attribute value different" << endl; + + if (os->collection_rmattr (cid, "alpha") != 0) + cout << "FAIL: collection_rmattr" << endl; + if (os->collection_rmattr (cid, "fred") != 0) + cout << "FAIL: collection_rmattr" << endl; + if (os->collection_rmattr (cid, "beta") != 0) + cout << "FAIL: collection_rmattr" << endl; + if (os->collection_rmattr (cid, "gamma") != 0) + cout << "FAIL: collection_rmattr" << endl; + + if (os->collection_rmattr (cid, "alpha") == 0) + cout << "FAIL: collection_rmattr (nonexistent)" << endl; + // Truncate the object. if (os->truncate (oid, 512, NULL) != 0) { -- 2.39.5