From dc8f0e05a9fcf7d27742aa91aeea24a8f7ce5553 Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 12 Mar 2007 03:08:54 +0000 Subject: [PATCH] undo previous broken merge of trunk r1171:1207 git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1209 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/cephmds2/Makefile | 2 +- branches/sage/cephmds2/cfuse.cc | 3 - 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/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/test/testos.cc | 3 +- branches/sage/cephmds2/test/testosbdb.cc | 134 +------ 25 files changed, 292 insertions(+), 721 deletions(-) diff --git a/branches/sage/cephmds2/Makefile b/branches/sage/cephmds2/Makefile index aaec92605dd0e..015b10c9f5c40 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 csyn newsyn fakesyn mkmonmap cmonctl cfuse fakefuse +TARGETS = cmon cosd cmds cfuse csyn newsyn fakesyn mkmonmap cmonctl SRCS=*.cc */*.cc *.h */*.h */*/*.h diff --git a/branches/sage/cephmds2/cfuse.cc b/branches/sage/cephmds2/cfuse.cc index 4b7e490c26b76..3c73c3d885a19 100644 --- a/branches/sage/cephmds2/cfuse.cc +++ b/branches/sage/cephmds2/cfuse.cc @@ -43,9 +43,6 @@ 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/common/Logger.cc b/branches/sage/cephmds2/common/Logger.cc index 91164658a80e5..bb9923d6a2cd3 100644 --- a/branches/sage/cephmds2/common/Logger.cc +++ b/branches/sage/cephmds2/common/Logger.cc @@ -34,14 +34,6 @@ 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 8565ce9effd92..43e2942e84c5f 100644 --- a/branches/sage/cephmds2/common/Thread.h +++ b/branches/sage/cephmds2/common/Thread.h @@ -45,9 +45,7 @@ class Thread { } int join(void **prval = 0) { - assert(thread_id); - //if (thread_id == 0) return -1; // never started. - + 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 522a623d5ebac..adacf0c5eb6c6 100644 --- a/branches/sage/cephmds2/common/Timer.cc +++ b/branches/sage/cephmds2/common/Timer.cc @@ -234,10 +234,6 @@ bool Timer::cancel_event(Context *callback) scheduled.erase(tp); lock.Unlock(); - - // delete the canceled event. - delete callback; - return true; } @@ -294,7 +290,7 @@ void SafeTimer::cancel_event(Context *c) if (g_timer.cancel_event(scheduled[c])) { // hosed wrapper. hose original event too. - delete c; + delete scheduled[c]; } else { // clean up later. canceled[c] = scheduled[c]; diff --git a/branches/sage/cephmds2/config.cc b/branches/sage/cephmds2/config.cc index ddbc606b726c1..3aee3ae8037c7 100644 --- a/branches/sage/cephmds2/config.cc +++ b/branches/sage/cephmds2/config.cc @@ -103,9 +103,6 @@ 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, @@ -133,6 +130,7 @@ 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 b507556e0c01c..d6e3b5142565c 100644 --- a/branches/sage/cephmds2/config.h +++ b/branches/sage/cephmds2/config.h @@ -81,9 +81,6 @@ struct md_config_t { int debug_after; - // misc - bool use_abspaths; - // clock bool clock_lock; @@ -111,6 +108,7 @@ 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 18f639f7176b6..25adf62606947 100644 --- a/branches/sage/cephmds2/ebofs/BlockDevice.h +++ b/branches/sage/cephmds2/ebofs/BlockDevice.h @@ -143,13 +143,6 @@ 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 f16e506a9dd63..e6b3fb39660e4 100644 --- a/branches/sage/cephmds2/ebofs/Table.h +++ b/branches/sage/cephmds2/ebofs/Table.h @@ -666,9 +666,8 @@ class Table { assert(cursor.open[cursor.level].size() == 0); assert(depth == 1); root = -1; - depth = 0; - if (cursor.open[0].node) - pool.release(cursor.open[0].node); + depth = 0; + 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 2edf3c7930e7a..1b8c526069711 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); - // FUSE will chdir("/"); be ready. - g_conf.use_abspaths = true; + // make monitorstore use abspath, since fuse seems to screw with the cwd + g_conf.mon_store_abspath = true; MonMap *monmap = new MonMap(g_conf.num_mon); diff --git a/branches/sage/cephmds2/fakesyn.cc b/branches/sage/cephmds2/fakesyn.cc index d4fc63a4cbba8..dca78939b9282 100644 --- a/branches/sage/cephmds2/fakesyn.cc +++ b/branches/sage/cephmds2/fakesyn.cc @@ -31,6 +31,9 @@ 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: @@ -94,9 +97,9 @@ int main(int argc, char **argv) } // create mds - MDS *mds[g_conf.num_mds]; - OSD *mdsosd[g_conf.num_mds]; - 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!) @@ -155,7 +158,7 @@ int main(int argc, char **argv) } - for (int i=0; ijoin_thread(); @@ -171,16 +174,13 @@ 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) { - if (gather->sub_finish(num)) - delete gather; // last one! + gather->finish(num); } }; - 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) { - //cout << "C_Gather new " << this << endl; - } - ~C_Gather() { - //cout << "C_Gather delete " << this << endl; - assert(!onfinish); - } + C_Gather(Context *f) : onfinish(f), num(0) {} + void finish(int r) { - // nobody should ever call me. - assert(0); + assert(waitfor.count(r)); + waitfor.erase(r); + if (waitfor.empty()) { + onfinish->finish(0); + delete onfinish; + } } + Context *new_sub() { + num++; + waitfor.insert(num); + return new C_GatherSub(this, num); + } }; #endif diff --git a/branches/sage/cephmds2/mds/MDS.cc b/branches/sage/cephmds2/mds/MDS.cc index c040bc1ee314b..d0f58817b314c 100644 --- a/branches/sage/cephmds2/mds/MDS.cc +++ b/branches/sage/cephmds2/mds/MDS.cc @@ -121,10 +121,6 @@ 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 d16b02e8aad51..6139df56d833e 100644 --- a/branches/sage/cephmds2/messages/MOSDOp.h +++ b/branches/sage/cephmds2/messages/MOSDOp.h @@ -93,9 +93,7 @@ private: eversion_t pg_trim_to; // primary->replica: trim to here int op; - size_t length; - off_t offset; - + size_t length, offset; eversion_t version; eversion_t old_version; @@ -138,7 +136,7 @@ private: void set_op(int o) { st.op = o; } const size_t get_length() { return st.length; } - const off_t get_offset() { return st.offset; } + const size_t get_offset() { return st.offset; } map& get_attrset() { return attrset; } void set_attrset(map &as) { attrset = as; } @@ -185,7 +183,7 @@ private: //void set_rg_nrep(int n) { st.rg_nrep = n; } void set_length(size_t l) { st.length = l; } - void set_offset(off_t o) { st.offset = o; } + void set_offset(size_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 55389973c8c6a..5185eb8206ded 100644 --- a/branches/sage/cephmds2/mon/MonitorStore.cc +++ b/branches/sage/cephmds2/mon/MonitorStore.cc @@ -36,12 +36,10 @@ void MonitorStore::mount() } ::closedir(d); - if (g_conf.use_abspaths) { + if (g_conf.mon_store_abspath) { // combine it with the cwd, in case fuse screws things up (i.e. fakefuse) string old = dir; - char *cwd = get_current_dir_name(); - dir = cwd; - delete cwd; + dir = get_current_dir_name(); dir += "/"; dir += old; } @@ -109,6 +107,7 @@ 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 fe9d54b189de6..43ec4eddf2eca 100644 --- a/branches/sage/cephmds2/mon/OSDMonitor.cc +++ b/branches/sage/cephmds2/mon/OSDMonitor.cc @@ -399,8 +399,6 @@ 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 7bf68c767e621..5a3aa3a78cc03 100644 --- a/branches/sage/cephmds2/msg/FakeMessenger.cc +++ b/branches/sage/cephmds2/msg/FakeMessenger.cc @@ -143,6 +143,7 @@ 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++; @@ -247,11 +248,7 @@ 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; + } @@ -262,6 +259,15 @@ 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]; @@ -297,37 +303,45 @@ 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 - if (directory.count(inst.addr)) { + // 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); + dout(1) << "--> " << get_myname() << " -> " << inst.name << " " << *m << " (" << m << ")" << endl; - 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; + + } + catch (...) { + cout << "no destination " << dest << endl; + assert(0); } + // 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 a60888a7dbb5a..45d5423561a83 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 || x <= g_conf.debug_bdbstore) cout << "bdbstore(" << device << ")@" << __LINE__ << "." +#define dout(x) if (x <= g_conf.debug_bdbstore) cout << "bdbstore(" << device << ")." #undef derr -#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_bdbstore) cerr << "bdbstore(" << device << ")@" << __LINE__ << "." +#define derr(x) if (x <= g_conf.debug_bdbstore) cerr << "bdbstore(" << device << ")." // Utilities. @@ -127,19 +127,13 @@ int OSBDB::mount() dout(2) << "mount " << device << endl; if (mounted) - { - dout(4) << "..already mounted" << endl; - return 0; - } + return 0; if (!opened) { int ret; if ((ret = opendb ()) != 0) - { - dout(4) << "..returns " << ret << endl; - return ret; - } + return ret; } // XXX Do we want anything else in the superblock? @@ -152,18 +146,12 @@ int OSBDB::mount() value.set_flags (DB_DBT_USERMEM | DB_DBT_PARTIAL); if (db->get (NULL, &key, &value, 0) != 0) - { - dout(4) << "..get superblock fails" << endl; - return -EINVAL; // XXX how to say "badly formed fs?" - } + return -EINVAL; // XXX how to say "badly formed fs?" - dout(3) << ".mount " << super << endl; + dout(2) << ".mount " << super << endl; if (super.version != OSBDB_THIS_VERSION) - { - dout(4) << "version mismatch (" << super.version << ")" << endl; - return -EINVAL; - } + return -EINVAL; DBTYPE t; db->get_type (&t); @@ -176,7 +164,7 @@ int OSBDB::mount() db->get_flags (&flags); dout(1) << "mounted version " << OSBDB_THIS_VERSION << "; Btree; " << "min keys per page: " << minkey << "; flags: " - << hex << flags << dec << endl; + << hex << flags << endl; cout << dec; } else @@ -190,12 +178,11 @@ int OSBDB::mount() dout(1) << "mounted version " << OSBDB_THIS_VERSION << "; Hash; " << "fill factor: " << ffactor << " table size: " << nelem << "; flags: " - << hex << flags << dec << endl; + << hex << flags << endl; cout << dec; } mounted = true; - dout(4) << "..mounted" << endl; return 0; } @@ -237,7 +224,6 @@ int OSBDB::umount() } mounted = false; opened = false; - dout(4) << "..unmounted" << endl; return 0; } @@ -282,7 +268,7 @@ int OSBDB::mkfs() return -EIO; } dout(3) << "..wrote superblock" << endl; - dout(4) << "..mkfs done" << endl; + return 0; } @@ -291,7 +277,6 @@ 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; } @@ -299,32 +284,22 @@ bool OSBDB::exists(object_t oid) { dout(2) << "exists " << oid << endl; struct stat st; - bool ret = (stat (oid, &st) == 0); - dout(4) << "..returns " << ret << endl; - return ret; + return (stat (oid, &st) == 0); } int OSBDB::statfs (struct statfs *st) { // Hacky? if (::statfs (device.c_str(), st) != 0) - { - int ret = -errno; - derr(1) << "statfs returns " << ret << endl; - return ret; - } + return -errno; st->f_type = OSBDB_MAGIC; - dout(4) << "..statfs OK" << endl; return 0; } int OSBDB::stat(object_t oid, struct stat *st) { if (!mounted) - { - dout(4) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "stat " << oid << endl; @@ -345,17 +320,13 @@ 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) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "remove " << oid << endl; @@ -367,7 +338,6 @@ 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); @@ -390,29 +360,20 @@ 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) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "truncate " << size << endl; if (size > 0xFFFFFFFF) - { - derr(1) << "object size too big!" << endl; - return -ENOSPC; - } + return -ENOSPC; DbTxn *txn = NULL; @@ -431,7 +392,6 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); - dout(4) << "..returns -ENOENT" << endl; return -ENOENT; } @@ -450,7 +410,6 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); - derr(1) << ".updating object failed" << endl; return -EIO; } @@ -460,7 +419,6 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); - derr(1) << ".updating object info failed" << endl; return -EIO; } } @@ -474,7 +432,6 @@ 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) @@ -488,7 +445,6 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); - derr(1) << ".updating object failed" << endl; return -EIO; } } @@ -503,7 +459,6 @@ 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()); @@ -513,7 +468,6 @@ int OSBDB::truncate(object_t oid, off_t size, Context *onsafe) { if (txn) txn->abort(); - derr(1) << ".putting new object failed" << endl; return -EIO; } } @@ -522,17 +476,13 @@ 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) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "read " << oid << " " << offset << " " << len << endl; @@ -580,10 +530,7 @@ int OSBDB::read(object_t oid, off_t offset, size_t len, bufferlist& bl) else { if (offset > obj.length) - { - dout(2) << "..offset out of range" << endl; - return 0; - } + return 0; if (offset + len > obj.length) len = obj.length - (size_t) offset; dout(3) << " doing partial read of " << len << endl; @@ -607,7 +554,6 @@ 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; } @@ -615,19 +561,13 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, bufferlist& bl, Context *onsafe) { if (!mounted) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "write " << oid << " " << offset << " " << len << endl; if (offset > 0xFFFFFFFFL || offset + len > 0xFFFFFFFFL) - { - derr(1) << "object too big" << endl; - return -ENOSPC; - } + return -ENOSPC; DbTxn *txn = NULL; if (transactional) @@ -641,18 +581,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; @@ -674,11 +614,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; @@ -686,8 +626,6 @@ 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; } @@ -712,7 +650,6 @@ int OSBDB::write(object_t oid, off_t offset, size_t len, { if (txn) txn->abort(); - derr(1) << "..writing object failed!" << endl; return -EIO; } } @@ -725,7 +662,6 @@ 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; } } @@ -741,33 +677,24 @@ 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) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "clone " << oid << ", " << noid << endl; if (exists (noid)) - { - dout(4) << "..target exists; returning -EEXIST" << endl; - return -EEXIST; - } + return -EEXIST; DbTxn *txn = NULL; if (transactional) @@ -794,14 +721,12 @@ 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()); @@ -810,21 +735,17 @@ 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; } @@ -833,10 +754,7 @@ int OSBDB::clone(object_t oid, object_t noid) int OSBDB::list_collections(list& ls) { if (!mounted) - { - derr(1) << "not mounted!" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "list_collections" << endl; @@ -845,29 +763,22 @@ int OSBDB::list_collections(list& ls) value.set_flags (DB_DBT_MALLOC); if (db->get (NULL, &key, &value, 0) != 0) - { - dout(4) << "..no collections" << endl; - return 0; // no collections. - } + 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) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; - dout(2) << "create_collection " << hex << c << dec << endl; + dout(2) << "create_collection " << c << endl; Dbt key (COLLECTIONS_KEY, 1); Dbt value; @@ -901,7 +812,6 @@ int OSBDB::create_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); - derr(1) << ".collection " << c << " already exists " << endl; return -EEXIST; } @@ -936,7 +846,6 @@ int OSBDB::create_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); - derr(1) << ".writing new collections list failed" << endl; return -EIO; } } @@ -951,27 +860,21 @@ 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) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; - dout(2) << "destroy_collection " << hex << c << dec << endl; + dout(2) << "destroy_collection " << c << endl; Dbt key (COLLECTIONS_KEY, 1); Dbt value; @@ -985,7 +888,6 @@ 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 } @@ -995,31 +897,23 @@ 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) + if (ins < scp->count - 1) { 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); @@ -1027,7 +921,6 @@ int OSBDB::destroy_collection(coll_t c, Context *onsafe) { if (txn != NULL) txn->abort(); - derr(1) << ".putting modified collection list failed" << endl; return -EIO; } @@ -1037,72 +930,41 @@ 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) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; - dout(2) << "collection_exists " << hex << c << dec << endl; + dout(2) << "collection_exists " << c << 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) - { - dout(4) << "..no collection list; return false" << endl; - return false; - } + 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) - { - dout(4) << "..empty collection list; return false" << endl; - return false; - } + 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;*/ - 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; + return (scp->colls[ins] == c); } int OSBDB::collection_stat(coll_t c, struct stat *st) { if (!mounted) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; dout(2) << "collection_stat " << c << endl; // XXX is this needed? @@ -1112,12 +974,9 @@ int OSBDB::collection_stat(coll_t c, struct stat *st) int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) { if (!mounted) - { - dout(2) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; - dout(2) << "collection_add " << hex << c << dec << " " << o << endl; + dout(2) << "collection_add " << c << " " << o << endl; Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -1131,7 +990,6 @@ 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; } @@ -1149,7 +1007,6 @@ 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; } } @@ -1159,11 +1016,9 @@ int OSBDB::collection_add(coll_t c, object_t o, Context *onsafe) scp = (stored_coll *) realloc (scp, sz); sc.release(); sc.reset (scp); - dout(3) << "..current collection: " << scp << endl; - if (ins < scp->count - 1) + if (ins < scp->count) { 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++; @@ -1176,25 +1031,20 @@ 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) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; - dout(2) << "collection_remove " << hex << c << dec << " " << o << endl; + dout(2) << "collection_remove " << c << " " << o << endl; Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -1208,35 +1058,29 @@ 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--; @@ -1248,23 +1092,18 @@ 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) - { - derr(1) << "not mounted" << endl; - return -EINVAL; - } + return -EINVAL; Dbt key (&c, sizeof (coll_t)); Dbt value; @@ -1322,7 +1161,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); @@ -1332,22 +1171,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 " << ((void *) sap) << " to " + dout(3) << " realloc 0x" << hex << ((void *) sap) << " to " << dec << sz << endl; sap = (stored_attrs *) realloc (sap, sz); - dout(3) << "..returns " << ((void *) sap) << endl; + dout(3) << " returns 0x" << hex << ((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]) << dec << endl; + << hex << (&sap->names[ins+1]) << endl; memmove (&sap->names[ins+1], &sap->names[ins], n); } memset (&sap->names[ins], 0, sizeof (attr_name)); @@ -1357,32 +1196,25 @@ 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) - { - derr(1) << ".writing attributes list failed" << endl; - return -EIO; - } + return -EIO; } else { - dout(3) << "..attribute " << name << " already exists" << endl; + dout(3) << " attribute " << name << " already exists" << endl; } - dout(5) << "..attributes list: " << sap << endl; + dout(3) << " 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) - { - derr(1) << ".writing attribute key failed" << endl; - return -EIO; - } + return -EIO; - dout(4) << "..setattr OK" << endl; return 0; } @@ -1449,23 +1281,17 @@ 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(); } @@ -1482,6 +1308,7 @@ 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++) { @@ -1490,17 +1317,15 @@ int OSBDB::getattrs(object_t oid, map& aset) (*it).second.length()); if (ret < 0) return ret; + count += ret; } - return 0; + return count; } 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; @@ -1521,39 +1346,29 @@ 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) - { - dout(4) << "..shift down by " << n << endl; - memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); - } + 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) @@ -1577,7 +1392,6 @@ int OSBDB::rmattr(object_t oid, const char *name, Context *onsafe) if (txn != NULL) txn->commit (0); - dout(4) << "..rmattr OK" << endl; return 0; } @@ -1615,8 +1429,6 @@ 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; } @@ -1629,13 +1441,10 @@ int OSBDB::collection_setattr(coll_t cid, const char *name, if (!mounted) return -EINVAL; - dout(2) << "collection_setattr " << hex << cid << dec << " " << name + dout(2) << "collection_setattr" << cid << " " << name << " (" << size << " bytes)" << endl; if (strlen (name) >= OSBDB_MAX_ATTR_LEN) - { - derr(1) << "name too long" << endl; - return -ENAMETOOLONG; - } + return -ENAMETOOLONG; // Add name to attribute list, if needed. coll_attrs_id aids = new_coll_attrs_id (cid); @@ -1675,10 +1484,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 " << hex << ((void *) sap) << " to " + dout(3) << " realloc 0x" << hex << ((void *) sap) << " to " << dec << sz << endl; sap = (stored_attrs *) realloc (sap, sz); - dout(3) << " returns " << hex << ((void *) sap) << dec << endl; + dout(3) << " returns 0x" << hex << ((void *) sap) << endl; sa.release (); sa.reset (sap); int n = (sap->count - ins) * sizeof (attr_name); @@ -1686,7 +1495,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]) << dec << endl; + << hex << (&sap->names[ins+1]) << endl; memmove (&sap->names[ins+1], &sap->names[ins], n); } memset (&sap->names[ins], 0, sizeof (attr_name)); @@ -1701,16 +1510,15 @@ 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); @@ -1721,14 +1529,11 @@ 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; } @@ -1738,9 +1543,6 @@ 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; @@ -1754,44 +1556,35 @@ 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) - { - dout(4) << "..shift down by " << n << endl; - memmove (&(sap->names[ins]), &(sap->names[ins + 1]), n); - } + 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) @@ -1815,8 +1608,6 @@ int OSBDB::collection_rmattr(coll_t cid, const char *name, if (txn != NULL) txn->commit (0); - - dout(4) << "..collection rmattr OK" << endl; return 0; } @@ -1826,8 +1617,7 @@ int OSBDB::collection_getattr(coll_t cid, const char *name, if (!mounted) return -EINVAL; - dout(2) << "collection_getattr " << hex << cid << dec - << " " << name << endl; + dout(2) << "collection_getattr " << cid << " " << name << endl; // XXX transactions/read isolation? @@ -1839,12 +1629,8 @@ 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) - { - derr(1) << ".no attribute entry" << endl; - return -ENOENT; - } + return -ENOENT; - dout(4) << "..collection getattr OK; returns " << val.get_size() << endl; return val.get_size(); } @@ -1853,7 +1639,7 @@ int OSBDB::collection_listattr(coll_t cid, char *attrs, size_t size) if (!mounted) return -EINVAL; - dout(2) << "collection_listattr " << hex << cid << dec << endl; + dout(2) << "collection_listattr " << cid << endl; // XXX transactions/read isolation? diff --git a/branches/sage/cephmds2/osd/OSD.cc b/branches/sage/cephmds2/osd/OSD.cc index 058692fab3fc0..4404822fb5e14 100644 --- a/branches/sage/cephmds2/osd/OSD.cc +++ b/branches/sage/cephmds2/osd/OSD.cc @@ -739,9 +739,8 @@ 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 " << inst + dout(0) << "ms_handle_failure " << dest << " inst " << inst << ", dropping and reporting to mon" << mon - << " " << *m << endl; messenger->send_message(new MOSDFailure(inst, osdmap->get_epoch()), monmap->get_inst(mon)); @@ -749,16 +748,15 @@ 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 " << inst + dout(0) << "ms_handle_failure " << dest << " inst " << inst << ", resending to mon" << mon - << " " << *m << endl; messenger->send_message(m, monmap->get_inst(mon)); } else { // client? - dout(0) << "ms_handle_failure " << inst - << ", dropping " << *m << endl; + dout(0) << "ms_handle_failure " << dest << " inst " << inst + << ", dropping" << endl; delete m; } } @@ -3437,7 +3435,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() + (off_t)op->get_length() >= (off_t)st.st_size) { + if (op->get_offset() + op->get_length() >= 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 dee6448b3494d..c77c7e7d0abd4 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 + (off_t)(bl.length() + sizeof(s))) / p) { + if (write_pos / p != (write_pos + 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, (off_t)(sizeof(s)+s-read_buf.length())); + fetch_len = MAX(fetch_len, 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 0933675ae2880..cb8db645f49e7 100644 --- a/branches/sage/cephmds2/osdc/ObjectCacher.cc +++ b/branches/sage/cephmds2/osdc/ObjectCacher.cc @@ -96,7 +96,50 @@ 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. @@ -331,25 +374,8 @@ 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; @@ -791,9 +817,6 @@ 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; @@ -1235,26 +1258,6 @@ 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. @@ -1363,24 +1366,6 @@ 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) { @@ -1399,15 +1384,8 @@ 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; } @@ -1424,7 +1402,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 e9a4041008666..27b154023209d 100644 --- a/branches/sage/cephmds2/osdc/ObjectCacher.h +++ b/branches/sage/cephmds2/osdc/ObjectCacher.h @@ -133,9 +133,6 @@ 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; } @@ -230,7 +227,16 @@ class ObjectCacher { objects_by_ino[ino].insert(o); return o; } - void close_object(Object *ob); + 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; + } // bh stats Cond stat_cond; @@ -309,22 +315,18 @@ 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); - dirty_bh.insert(bh); - } else { + 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); - dirty_bh.erase(bh); - } else { + else lru_rest.lru_remove(bh); - } bh_stat_sub(bh); } @@ -337,7 +339,6 @@ class ObjectCacher { bool flush(Object *o); off_t release(Object *o); - void purge(Object *o); void rdlock(Object *o); void rdunlock(Object *o); @@ -412,17 +413,10 @@ class ObjectCacher { flusher_thread.create(); } ~ObjectCacher() { - // 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! + //lock.Lock(); // hmm.. watch out for deadlock! flusher_stop = true; flusher_cond.Signal(); - lock.Unlock(); + //lock.Unlock(); flusher_thread.join(); } @@ -463,8 +457,6 @@ 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 9e49a43ace89b..ddd22325747db 100644 --- a/branches/sage/cephmds2/osdc/Objecter.cc +++ b/branches/sage/cephmds2/osdc/Objecter.cc @@ -269,31 +269,27 @@ tid_t Objecter::stat_submit(OSDStat *st) ObjectExtent &ex = st->extents.front(); PG &pg = get_pg( ex.pgid ); - // pick tid + // send last_tid++; assert(client_inc >= 0); - - // add to gather set - st->tid = last_tid; - op_stat[last_tid] = st; - - pg.active_tids.insert(last_tid); - - // send? + MOSDOp *m = new MOSDOp(messenger->get_myinst(), client_inc, last_tid, + ex.oid, ex.pgid, osdmap->get_epoch(), + OSD_OP_STAT); dout(10) << "stat_submit " << st << " tid " << last_tid << " oid " << ex.oid << " pg " << ex.pgid << " osd" << pg.acker() << endl; - 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); - + if (pg.acker() >= 0) 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; } @@ -385,17 +381,14 @@ tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex) // find OSD PG &pg = get_pg( ex.pgid ); - // pick tid + // send last_tid++; assert(client_inc >= 0); - - // add to gather set - rd->ops[last_tid] = ex; - op_read[last_tid] = rd; - - pg.active_tids.insert(last_tid); - - // send? + 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); dout(10) << "readx_submit " << rd << " tid " << last_tid << " oid " << ex.oid << " " << ex.start << "~" << ex.length << " (" << ex.buffer_extents.size() << " buffer fragments)" @@ -403,16 +396,15 @@ tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex) << " osd" << pg.acker() << endl; - 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); - + if (pg.acker() >= 0) 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; } @@ -649,13 +641,43 @@ tid_t Objecter::modifyx_submit(OSDModify *wr, ObjectExtent &ex, tid_t usetid) // find PG &pg = get_pg( ex.pgid ); - // pick tid + // send 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; @@ -665,46 +687,15 @@ 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) { - 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; - } - + if (pg.primary() >= 0) messenger->send_message(m, osdmap->get_inst(pg.primary())); - } dout(5) << num_unacked << " unacked, " << num_uncommitted << " uncommitted" << endl; diff --git a/branches/sage/cephmds2/test/testos.cc b/branches/sage/cephmds2/test/testos.cc index 24c81590d899c..ee27a16ee4786 100644 --- a/branches/sage/cephmds2/test/testos.cc +++ b/branches/sage/cephmds2/test/testos.cc @@ -216,14 +216,13 @@ 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 19268e7587531..50a4ee663fcff 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 = 10; + g_conf.debug_bdbstore = 3; //g_conf.bdbstore_btree = true; char dbfile[256]; strncpy (dbfile, "/tmp/testosbdb/db.XXXXXX", 256); @@ -123,73 +123,6 @@ 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) { @@ -253,71 +186,6 @@ 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