*
*/
-
-
#ifndef __LOGEVENT_H
#define __LOGEVENT_H
-#ifndef __EALLOC_H
-#define __EALLOC_H
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#ifndef __MDS_EALLOC_H
+#define __MDS_EALLOC_H
#include <assert.h>
#include "config.h"
public:
EAlloc() : LogEvent(EVENT_ALLOC) { }
EAlloc(int idtype, idno_t id, int what, version_t v) :
- LogEvent(EVENT_ALLOC) {
- this->idtype = idtype;
- this->id = id;
- this->what = what;
- this->table_version = v;
+ LogEvent(EVENT_ALLOC) {
+ this->idtype = idtype;
+ this->id = id;
+ this->what = what;
+ this->table_version = v;
}
void encode_payload(bufferlist& bl) {
- bl.append((char*)&idtype, sizeof(idtype));
- bl.append((char*)&id, sizeof(id));
- bl.append((char*)&what, sizeof(what));
- bl.append((char*)&table_version, sizeof(table_version));
+ bl.append((char*)&idtype, sizeof(idtype));
+ bl.append((char*)&id, sizeof(id));
+ bl.append((char*)&what, sizeof(what));
+ bl.append((char*)&table_version, sizeof(table_version));
}
void decode_payload(bufferlist& bl, int& off) {
- bl.copy(off, sizeof(idtype), (char*)&idtype);
- off += sizeof(idtype);
- bl.copy(off, sizeof(id), (char*)&id);
- off += sizeof(id);
- bl.copy(off, sizeof(what), (char*)&what);
- off += sizeof(what);
- bl.copy(off, sizeof(table_version), (char*)&table_version);
- off += sizeof(table_version);
+ bl.copy(off, sizeof(idtype), (char*)&idtype);
+ off += sizeof(idtype);
+ bl.copy(off, sizeof(id), (char*)&id);
+ off += sizeof(id);
+ bl.copy(off, sizeof(what), (char*)&what);
+ off += sizeof(what);
+ bl.copy(off, sizeof(table_version), (char*)&table_version);
+ off += sizeof(table_version);
}
void print(ostream& out) {
- if (what == EALLOC_EV_ALLOC)
- out << "alloc " << hex << id << dec << " tablev " << table_version;
- else
- out << "dealloc " << hex << id << dec << " tablev " << table_version;
+ if (what == EALLOC_EV_ALLOC)
+ out << "alloc " << hex << id << dec << " tablev " << table_version;
+ else
+ out << "dealloc " << hex << id << dec << " tablev " << table_version;
}
// live journal
bool can_expire(MDS *mds) {
- if (mds->idalloc->get_committed_version() <= table_version)
- return false; // still dirty
- else
- return true; // already flushed
+ if (mds->idalloc->get_committed_version() <= table_version)
+ return false; // still dirty
+ else
+ return true; // already flushed
}
-
+
void retire(MDS *mds, Context *c) {
- mds->idalloc->save(c, table_version);
+ mds->idalloc->save(c, table_version);
}
-
-
+
+
// recovery
bool has_happened(MDS *mds) {
- if (mds->idalloc->get_version() >= table_version) {
- cout << " event " << table_version << " <= table " << mds->idalloc->get_version() << endl;
- return true;
- } else
- return false;
+ if (mds->idalloc->get_version() >= table_version) {
+ cout << " event " << table_version << " <= table " << mds->idalloc->get_version() << endl;
+ return true;
+ } else
+ return false;
}
void replay(MDS *mds) {
- assert(table_version-1 == mds->idalloc->get_version());
-
- if (what == EALLOC_EV_ALLOC) {
- idno_t nid = mds->idalloc->alloc_id(true);
- assert(nid == id); // this should match.
- }
- else if (what == EALLOC_EV_FREE) {
- mds->idalloc->reclaim_id(id, true);
- }
- else
- assert(0);
-
- assert(table_version == mds->idalloc->get_version());
+ assert(table_version-1 == mds->idalloc->get_version());
+
+ if (what == EALLOC_EV_ALLOC) {
+ idno_t nid = mds->idalloc->alloc_id(true);
+ assert(nid == id); // this should match.
+ }
+ else if (what == EALLOC_EV_FREE) {
+ mds->idalloc->reclaim_id(id, true);
+ }
+ else
+ assert(0);
+
+ assert(table_version == mds->idalloc->get_version());
}
};
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
#ifndef __EDIRUPDATE_H
#define __EDIRUPDATE_H
public:
EDirUpdate(CDir *dir) :
- LogEvent(EVENT_DIRUPDATE) {
- this->dirino = dir->ino();
- version = dir->get_version();
+ LogEvent(EVENT_DIRUPDATE) {
+ this->dirino = dir->ino();
+ version = dir->get_version();
}
EDirUpdate() :
- LogEvent(EVENT_DIRUPDATE) {
+ LogEvent(EVENT_DIRUPDATE) {
}
virtual void encode_payload(bufferlist& bl) {
- bl.append((char*)&version, sizeof(version));
- bl.append((char*)&dirino, sizeof(dirino));
+ bl.append((char*)&version, sizeof(version));
+ bl.append((char*)&dirino, sizeof(dirino));
}
void decode_payload(bufferlist& bl, int& off) {
- bl.copy(off, sizeof(version), (char*)&version);
- off += sizeof(version);
- bl.copy(off, sizeof(dirino), (char*)&dirino);
- off += sizeof(dirino);
+ bl.copy(off, sizeof(version), (char*)&version);
+ off += sizeof(version);
+ bl.copy(off, sizeof(dirino), (char*)&dirino);
+ off += sizeof(dirino);
}
virtual bool can_expire(MDS *mds) {
- // am i obsolete?
- CInode *in = mds->mdcache->get_inode(dirino);
- if (!in) return true;
- CDir *dir = in->dir;
- if (!dir) return true;
+ // am i obsolete?
+ CInode *in = mds->mdcache->get_inode(dirino);
+ if (!in) return true;
+ CDir *dir = in->dir;
+ if (!dir) return true;
- dout(10) << "EDirUpdate v " << version << " on dir " << *dir << endl;
+ dout(10) << "EDirUpdate v " << version << " on dir " << *dir << endl;
- if (!dir->is_auth()) return true; // not mine!
- if (dir->is_frozen()) return true; // frozen -> exporting -> obsolete? FIXME
-
- if (!dir->is_dirty()) return true;
+ if (!dir->is_auth()) return true; // not mine!
+ if (dir->is_frozen()) return true; // frozen -> exporting -> obsolete? FIXME
+
+ if (!dir->is_dirty()) return true;
- if (dir->get_committing_version() > version)
- return true;
+ if (dir->get_committing_version() > version)
+ return true;
- return false;
+ return false;
}
virtual void retire(MDS *mds, Context *c) {
- // commit directory
- CInode *in = mds->mdcache->get_inode(dirino);
- assert(in);
- CDir *dir = in->dir;
- assert(dir);
+ // commit directory
+ CInode *in = mds->mdcache->get_inode(dirino);
+ assert(in);
+ CDir *dir = in->dir;
+ assert(dir);
- dout(10) << "EDirUpdate committing dir " << *dir << endl;
- mds->mdstore->commit_dir(dir, c);
+ dout(10) << "EDirUpdate committing dir " << *dir << endl;
+ mds->mdstore->commit_dir(dir, c);
}
};
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
#ifndef __EINODEUPDATE_H
#define __EINODEUPDATE_H
public:
EInodeUpdate(CInode *in) :
- LogEvent(EVENT_INODEUPDATE) {
- this->inode = in->inode;
- version = in->get_version();
+ LogEvent(EVENT_INODEUPDATE) {
+ this->inode = in->inode;
+ version = in->get_version();
}
EInodeUpdate() :
- LogEvent(EVENT_INODEUPDATE) {
+ LogEvent(EVENT_INODEUPDATE) {
}
virtual void encode_payload(bufferlist& bl) {
- bl.append((char*)&version, sizeof(version));
- bl.append((char*)&inode, sizeof(inode));
+ bl.append((char*)&version, sizeof(version));
+ bl.append((char*)&inode, sizeof(inode));
}
void decode_payload(bufferlist& bl, int& off) {
- bl.copy(off, sizeof(version), (char*)&version);
- off += sizeof(version);
- bl.copy(off, sizeof(inode), (char*)&inode);
- off += sizeof(inode);
+ bl.copy(off, sizeof(version), (char*)&version);
+ off += sizeof(version);
+ bl.copy(off, sizeof(inode), (char*)&inode);
+ off += sizeof(inode);
}
bool can_expire(MDS *mds) {
- // am i obsolete?
- CInode *in = mds->mdcache->get_inode(inode.ino);
+ // am i obsolete?
+ CInode *in = mds->mdcache->get_inode(inode.ino);
- //assert(in);
- if (!in) {
- dout(7) << "inode " << inode.ino << " not in cache, must have exported" << endl;
- return true;
- }
- dout(7) << "EInodeUpdate obsolete? on " << *in << endl;
- if (!in->is_auth())
- return true; // not my inode anymore!
- if (in->get_version() != version)
- return true; // i'm obsolete! (another log entry follows)
+ //assert(in);
+ if (!in) {
+ dout(7) << "inode " << inode.ino << " not in cache, must have exported" << endl;
+ return true;
+ }
+ dout(7) << "EInodeUpdate obsolete? on " << *in << endl;
+ if (!in->is_auth())
+ return true; // not my inode anymore!
+ if (in->get_version() != version)
+ return true; // i'm obsolete! (another log entry follows)
- CDir *parent = in->get_parent_dir();
- if (!parent) return true; // root?
- if (!parent->is_dirty()) return true; // dir is clean!
+ CDir *parent = in->get_parent_dir();
+ if (!parent) return true; // root?
+ if (!parent->is_dirty()) return true; // dir is clean!
- // frozen -> exporting -> obsolete (FOR NOW?)
- if (in->is_frozen())
- return true;
+ // frozen -> exporting -> obsolete (FOR NOW?)
+ if (in->is_frozen())
+ return true;
- return false;
+ return false;
}
virtual void retire(MDS *mds, Context *c) {
- // commit my containing directory
- CInode *in = mds->mdcache->get_inode(inode.ino);
- assert(in);
- CDir *parent = in->get_parent_dir();
+ // commit my containing directory
+ CInode *in = mds->mdcache->get_inode(inode.ino);
+ assert(in);
+ CDir *parent = in->get_parent_dir();
- if (parent) {
- // okay!
- dout(7) << "commiting containing dir for " << *in << ", which is " << *parent << endl;
- mds->mdstore->commit_dir(parent, c);
- } else {
- // oh, i'm the root inode
- dout(7) << "don't know how to commit the root inode" << endl;
- if (c) {
- c->finish(0);
- delete c;
- }
- }
+ if (parent) {
+ // okay!
+ dout(7) << "commiting containing dir for " << *in << ", which is " << *parent << endl;
+ mds->mdstore->commit_dir(parent, c);
+ } else {
+ // oh, i'm the root inode
+ dout(7) << "don't know how to commit the root inode" << endl;
+ if (c) {
+ c->finish(0);
+ delete c;
+ }
+ }
}
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
#ifndef __ESTRING_H
#define __ESTRING_H
public:
EString(string e) :
- LogEvent(EVENT_STRING) {
- event = e;
+ LogEvent(EVENT_STRING) {
+ event = e;
}
EString() :
- LogEvent(EVENT_STRING) {
+ LogEvent(EVENT_STRING) {
}
void decode_payload(bufferlist& bl, int& off) {
- event = bl.c_str() + off;
- off += event.length() + 1;
+ event = bl.c_str() + off;
+ off += event.length() + 1;
}
void encode_payload(bufferlist& bl) {
- bl.append(event.c_str(), event.length()+1);
+ bl.append(event.c_str(), event.length()+1);
+ }
+
+ void print(ostream& out) {
+ out << '"' << event << '"';
}
+
};
#endif
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+
+#ifndef __MDS_ETRACED_H
+#define __MDS_ETRACED_H
+
+#include <stdlib.h>
+#include <string>
+using namespace std;
+
+#include "../LogEvent.h"
+
+// generic log event
+class ETraced : public LogEvent {
+ struct bit {
+ inodeno_t dirino;
+ version_t dirv;
+ string dn;
+ inodeno_t ino;
+ version_t inov;
+
+ bit() {}
+ bit(inodeno_t di, version_t dv, string& d, inodeno_t i, version_t iv) :
+ dirino(di), dirv(dv), dn(d), ino(i), inov(iv) {}
+
+ void _encode(bufferlist& bl) {
+ bl.append((char*)&dirino, sizeof(dirino));
+ bl.append((char*)&dirv, sizeof(dirv));
+ ::_encode(dn,bl);
+ bl.append((char*)&ino, sizeof(ino));
+ bl.append((char*)&inov, sizeof(inov));
+ }
+ void _decode(bufferlist& bl, int& off) {
+ bl.copy(off, sizeof(dirino), (char*)&dirino); off += sizeof(dirino);
+ bl.copy(off, sizeof(dirv), (char*)&dirv); off += sizeof(dirv);
+ ::_decode(dn, bl, off);
+ bl.copy(off, sizeof(ino), (char*)&ino); off += sizeof(ino);
+ bl.copy(off, sizeof(inov), (char*)&inov); off += sizeof(inov);
+ }
+ };
+
+ protected:
+ list<bit> trace;
+
+ public:
+ ETraced(int t) : LogEvent(t) { }
+
+ void decode_trace(bufferlist& bl, int& off) {
+ int n;
+ bl.copy(off, sizeof(n), (char*)&n);
+ off += n;
+ for (int i=0; i<n; i++) {
+ trace.push_back(bit());
+ trace.back()._decode(bl,off);
+ }
+ }
+
+ void encode_trace(bufferlist& bl) {
+ int n = trace.size();
+ bl.append((char*)&n, sizeof(n));
+ for (list<bit>::iterator i = trace.begin();
+ i != trace.end();
+ i++)
+ i->_encode(bl);
+ }
+
+ void print(ostream& out) {
+ out << '"' << event << '"';
+ }
+
+};
+
+#endif
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
#ifndef __EUNLINK_H
#define __EUNLINK_H
public:
EUnlink(CDir *dir, CDentry* dn) :
- LogEvent(EVENT_UNLINK) {
- this->dir_ino = dir->ino();
- this->dname = dn->get_name();
- this->version = dir->get_version();
+ LogEvent(EVENT_UNLINK) {
+ this->dir_ino = dir->ino();
+ this->dname = dn->get_name();
+ this->version = dir->get_version();
}
EUnlink() :
- LogEvent(EVENT_UNLINK) {
+ LogEvent(EVENT_UNLINK) {
}
virtual void encode_payload(bufferlist& bl) {
- bl.append((char*)&dir_ino, sizeof(dir_ino));
- bl.append((char*)&version, sizeof(version));
- bl.append((char*)dname.c_str(), dname.length() + 1);
+ bl.append((char*)&dir_ino, sizeof(dir_ino));
+ bl.append((char*)&version, sizeof(version));
+ bl.append((char*)dname.c_str(), dname.length() + 1);
}
void decode_payload(bufferlist& bl, int& off) {
- bl.copy(off, sizeof(dir_ino), (char*)&dir_ino);
- off += sizeof(dir_ino);
- bl.copy(off, sizeof(version), (char*)&version);
- off += sizeof(version);
- dname = bl.c_str() + off;
- off += dname.length() + 1;
+ bl.copy(off, sizeof(dir_ino), (char*)&dir_ino);
+ off += sizeof(dir_ino);
+ bl.copy(off, sizeof(version), (char*)&version);
+ off += sizeof(version);
+ dname = bl.c_str() + off;
+ off += dname.length() + 1;
}
virtual bool can_expire(MDS *mds) {
- // am i obsolete?
- CInode *idir = mds->mdcache->get_inode(dir_ino);
- if (!idir) return true;
+ // am i obsolete?
+ CInode *idir = mds->mdcache->get_inode(dir_ino);
+ if (!idir) return true;
- CDir *dir = idir->dir;
+ CDir *dir = idir->dir;
- if (!dir) return true;
+ if (!dir) return true;
- if (!idir->dir->is_auth()) return true;
- if (idir->dir->is_clean()) return true;
+ if (!idir->dir->is_auth()) return true;
+ if (idir->dir->is_clean()) return true;
- if (idir->dir->get_last_committed_version() >= version) return true;
- return false;
+ if (idir->dir->get_last_committed_version() >= version) return true;
+ return false;
}
virtual void retire(MDS *mds, Context *c) {
- // commit my containing directory
- CDir *dir = mds->mdcache->get_inode(dir_ino)->dir;
- assert(dir);
-
- // okay!
- dout(7) << "commiting dirty (from unlink) dir " << *dir << endl;
- mds->mdstore->commit_dir(dir, version, c);
+ // commit my containing directory
+ CDir *dir = mds->mdcache->get_inode(dir_ino)->dir;
+ assert(dir);
+
+ // okay!
+ dout(7) << "commiting dirty (from unlink) dir " << *dir << endl;
+ mds->mdstore->commit_dir(dir, version, c);
}
};