From 7498ac942e04f89090ce8ea9e8a52558e7dfe0a0 Mon Sep 17 00:00:00 2001 From: sage Date: Sat, 2 Apr 2005 15:50:43 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@130 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/mds/Lock.h | 2 +- ceph/mds/MDCache.cc | 44 +++++++++++++++-- ceph/mds/MDCache.h | 5 ++ ceph/messages/MLock.h | 109 ++++++++++++++++++++++++++++++++++++++++++ ceph/msg/Message.h | 2 + 5 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 ceph/messages/MLock.h diff --git a/ceph/mds/Lock.h b/ceph/mds/Lock.h index 40f906bd981..5fccdb55748 100644 --- a/ceph/mds/Lock.h +++ b/ceph/mds/Lock.h @@ -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", diff --git a/ceph/mds/MDCache.cc b/ceph/mds/MDCache.cc index e34b148d0f5..300fe28bb36 100644 --- a/ceph/mds/MDCache.cc +++ b/ceph/mds/MDCache.cc @@ -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. */ diff --git a/ceph/mds/MDCache.h b/ceph/mds/MDCache.h index 0725e47aa13..3d33ff91911 100644 --- a/ceph/mds/MDCache.h +++ b/ceph/mds/MDCache.h @@ -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 index 00000000000..693365836e8 --- /dev/null +++ b/ceph/messages/MLock.h @@ -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 diff --git a/ceph/msg/Message.h b/ceph/msg/Message.h index 246c45b6e51..6c7917d0e24 100644 --- a/ceph/msg/Message.h +++ b/ceph/msg/Message.h @@ -66,6 +66,8 @@ #define MSG_MDS_RENAMELOCALFILE 300 +#define MSG_MDS_LOCK 500 + #define MSG_MDS_SHUTDOWNSTART 900 #define MSG_MDS_SHUTDOWNFINISH 901