]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 2 Apr 2005 15:50:43 +0000 (15:50 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 2 Apr 2005 15:50:43 +0000 (15:50 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@130 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/mds/Lock.h
ceph/mds/MDCache.cc
ceph/mds/MDCache.h
ceph/messages/MLock.h [new file with mode: 0644]
ceph/msg/Message.h

index 40f906bd981dfe820a136ceff102c550db0a664b..5fccdb55748350b00e65800786a5d13b682bec23 100644 (file)
@@ -51,7 +51,7 @@ class BasicLock {
   }
 };
 
-ostream& operator<<(ostream& out, BasicLock& l) {
+inline ostream& operator<<(ostream& out, BasicLock& l) {
   static char* __lock_states[] = {
        "sync",
        "prelock",
index e34b148d0f52584094d0686133cfc227dbef75ca..300fe28bb36d5aa1fb44541e26cf73d48539be0a 100644 (file)
@@ -43,6 +43,8 @@
 #include "messages/MInodeUnlink.h"
 #include "messages/MInodeUnlinkAck.h"
 
+#include "messages/MLock.h"
+
 #include "messages/MInodeSyncStart.h"
 #include "messages/MInodeSyncAck.h"
 #include "messages/MInodeSyncRelease.h"
@@ -1736,9 +1738,7 @@ INODES:
     - truncate ... need to stop writers for the atomic truncate operation
       - need a full lock
 
-
-
-
+ ????
 
 
 ALSO:
@@ -1747,10 +1747,43 @@ ALSO:
   denlock  - dentry lock    (prior to unlink, rename)
 
      
+*/
+
+
+/*
+void MDCache::handle_lock(MLock *m)
+{
+  // action type
+  switch (m->get_otype()) {
+  case LOCK_OTYPE_INO:
+       CInode *in = get_inode(m->get_ino());
+       
+       break;
+
+  case LOCK_OTYPE_DIRINO:
+       CInode *in = get_inode(m->get_ino());
+       CDir *dir = in->dir;
+       break;
+       
+       
+  case LOCK_OTYPE_DN:
+       CInode *in = get_inode(m->get_ino());
+       CDir *dir = in->dir;
+       CDentry = dir->lookup(m->get_dn());
+       
+       break;
+  } 
+  
+}
+
+*/
+
+
+/*
 
+OLD LOCK CRAP
 
 
-OLD CRAP:
  (old):
   sync -  soft metadata.. no reads/writes can proceed.  (eg no stat)
   lock -  hard(+soft) metadata.. path traversals stop etc.  (??)
@@ -1800,6 +1833,9 @@ NAMESPACE:
 */
 
 
+
+
+
 /* soft sync locks: mtime, size, etc. 
  */
 
index 0725e47aa133da93866e94da6476d7f50cc5ca39..3d33ff9191103ae85faf30b1194534549c3992dd 100644 (file)
@@ -42,6 +42,9 @@ class MInodeSyncRecall;
 class MInodeLockStart;
 class MInodeLockAck;
 class MInodeLockRelease;
+
+class MLock;
+
 class MDirSyncStart;
 class MDirSyncAck;
 class MDirSyncRelease;
@@ -313,6 +316,8 @@ class MDCache {
   void handle_inode_lock_ack(MInodeLockAck *m);
   void handle_inode_lock_release(MInodeLockRelease *m);
                          
+  void handle_lock(MLock *m);
+
 
   // -- sync : dirs --
   void dir_sync_start(CDir *dir);
diff --git a/ceph/messages/MLock.h b/ceph/messages/MLock.h
new file mode 100644 (file)
index 0000000..6933658
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef __MLOCK_H
+#define __MLOCK_H
+
+#include "include/Message.h"
+
+#define LOCK_OTYPE_INO    1
+#define LOCK_OTYPE_DIRINO 2
+#define LOCK_OTYPE_DN     3
+
+// basic messages
+#define LOCK_AC_LOCK          1
+#define LOCK_AC_LOCKACK       2
+#define LOCK_AC_SYNC          3
+#define LOCK_AC_SYNCACK       4
+#define LOCK_AC_REQSYNC       5
+#define LOCK_AC_DELETE        6
+#define LOCK_AC_DELETEACK     7
+
+// async messages
+#define LOCK_AC_ASYNC         8
+#define LOCK_AC_ASYNCACK      9
+#define LOCK_AC_REQASYNC     10
+
+
+class MLock : public Message {
+  int       asker;  // who is initiating this request
+  int       action;  // action type
+
+  char      otype;  // lock object type
+  inodeno_t ino;    // ino ref, or possibly
+  string    dn;     // dentry name
+  crope     data;   // and possibly some data
+
+ public:
+  inodeno_t get_ino() { return ino; }
+  string& get_dn() { return dn; }
+  crope& get_data() { return data; }
+  int get_asker() { return asker; }
+  int get_action() { return action; }
+  int get_otype() { return otype; }
+
+  MLock() {}
+  MLock(int action, int asker) :
+       Message(MSG_MDS_LOCK) {
+       this->action = action;
+       this->asker = asker;
+  }
+  virtual char *get_type_name() { return "ILock"; }
+  
+  void set_ino(inodeno_t ino) {
+       otype = LOCK_OTYPE_INO;
+       this->ino = ino;
+  }
+  void set_dirino(inodeno_t dirino) {
+       otype = LOCK_OTYPE_DIRINO;
+       this->ino = ino;
+  }
+  void set_dn(inodeno_t dirino, string& dn) {
+       otype = LOCK_OTYPE_DN;
+       this->ino = dirino;
+       this->dn = dn;
+  }
+  void set_data(crope& data) {
+       this->data = data;
+  }
+  
+  virtual int decode_payload(crope s) {
+       int off = 0;
+       s.copy(off,sizeof(action), (char*)&action);
+       off += sizeof(action);
+
+       s.copy(off,sizeof(asker), (char*)&asker);
+       off += sizeof(asker);
+       
+       s.copy(off,sizeof(otype), (char*)&otype);
+       off += sizeof(otype);
+
+       s.copy(off,sizeof(inodeno_t), (char*)&ino);
+       off += sizeof(ino);
+       
+       dn = s.c_str() + off;
+       off += dn.length() + 1;
+
+       int len;
+       s.copy(off, sizeof(len), (char*)&len);
+       off += sizeof(len);
+       data = s.substr(off, len);
+       off += len;
+  }
+  virtual crope get_payload() {
+       crope s;
+       s.append((char*)&action, sizeof(action));
+       s.append((char*)&asker, sizeof(asker));
+
+       s.append((char*)&otype, sizeof(otype));
+
+       s.append((char*)&ino, sizeof(inodeno_t));
+
+       s.append((char*)dn.c_str(), dn.length()+1);
+
+       int len = data.length();
+       s.append((char*)len, sizeof(len));
+       s.append(data);
+       return s;
+  }
+
+};
+
+#endif
index 246c45b6e518dae3ad5c32143b34324c04c0d30a..6c7917d0e24dc4d9b1313a4490898977e2d3de55 100644 (file)
@@ -66,6 +66,8 @@
 
 #define MSG_MDS_RENAMELOCALFILE  300
 
+#define MSG_MDS_LOCK             500
+
 #define MSG_MDS_SHUTDOWNSTART  900
 #define MSG_MDS_SHUTDOWNFINISH 901