]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
event fun
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Wed, 25 Oct 2006 18:17:24 +0000 (18:17 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Wed, 25 Oct 2006 18:17:24 +0000 (18:17 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@947 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/mds/LogEvent.h
ceph/mds/events/EAlloc.h
ceph/mds/events/EDirUpdate.h
ceph/mds/events/EInodeUpdate.h
ceph/mds/events/EString.h
ceph/mds/events/ETraced.h [new file with mode: 0644]
ceph/mds/events/EUnlink.h

index b2f29735d8d6f4047bc3bb6a62ced5d0ea89c53e..410f2953a44a0ba0b60b945813261ed8aef7518e 100644 (file)
@@ -11,8 +11,6 @@
  * 
  */
 
-
-
 #ifndef __LOGEVENT_H
 #define __LOGEVENT_H
 
index 9959e5704bfbe7456953bac76fd8ce8a537193eb..049a20e13ab127dc0d8f64e0c7f2edb60895b0fd 100644 (file)
@@ -1,5 +1,18 @@
-#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"
@@ -21,75 +34,75 @@ class EAlloc : public LogEvent {
  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());
   }
   
 };
index 9c90a518b4204526505e6e10a2b5ae394db44c10..6411a0d37d8fefa176c52f12f832c7b52379afee 100644 (file)
@@ -1,3 +1,16 @@
+// -*- 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
 
@@ -18,55 +31,55 @@ class EDirUpdate : public LogEvent {
 
  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);
   }
   
 };
index 3601c6960cd2384ab197e4cfdccdfa75a58a3303..8220760ac11c59590b48677f1e281a776b78e24a 100644 (file)
@@ -1,3 +1,16 @@
+// -*- 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
 
@@ -18,70 +31,70 @@ class EInodeUpdate : public LogEvent {
 
  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;
+      }
+    }
 
   }
   
index face114bfea276e2127ecebc074cff61b46240eb..6bd10030549bab5d7c95599031e7d911d6906bb8 100644 (file)
@@ -1,3 +1,16 @@
+// -*- 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
@@ -15,21 +28,26 @@ class EString : public LogEvent {
 
  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
diff --git a/ceph/mds/events/ETraced.h b/ceph/mds/events/ETraced.h
new file mode 100644 (file)
index 0000000..de1347d
--- /dev/null
@@ -0,0 +1,84 @@
+// -*- 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
index 874440280f1f4f10f914feb8d8035cf76bfadb24..ccea623bfebff87ece5bcfa746b1a4b606791d80 100644 (file)
@@ -1,3 +1,16 @@
+// -*- 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
 
@@ -19,53 +32,53 @@ class EUnlink : public LogEvent {
 
  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);
   }
 };