]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add messenging support for advisory file locking
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 20 Apr 2010 21:45:30 +0000 (14:45 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Mon, 2 Aug 2010 17:39:55 +0000 (10:39 -0700)
src/include/ceph_fs.h
src/mds/mdstypes.h

index bd045bebc83feb9793f108522b56addb7875f6e4..8c4bc649ffd19fa11200bc11437048ef4177da70 100644 (file)
@@ -301,6 +301,8 @@ enum {
        CEPH_MDS_OP_RMXATTR    = 0x01106,
        CEPH_MDS_OP_SETLAYOUT  = 0x01107,
        CEPH_MDS_OP_SETATTR    = 0x01108,
+       CEPH_MDS_OP_SETFILELOCK= 0x01109,
+       CEPH_MDS_OP_GETFILELOCK= 0x00110,
 
        CEPH_MDS_OP_MKNOD      = 0x01201,
        CEPH_MDS_OP_LINK       = 0x01202,
@@ -371,6 +373,15 @@ union ceph_mds_request_args {
        struct {
                struct ceph_file_layout layout;
        } __attribute__ ((packed)) setlayout;
+       struct {
+               __u8 rule; /* currently fcntl or flock */
+               __u8 type; /* shared, exclusive, remove*/
+               int pid; /* process id requesting the lock */
+               __u64 pid_namespace;
+               __u64 start; /* initial location to lock */
+               __u64 length; /* num bytes to lock from start */
+               bool wait; /* will caller wait for lock to become available? */
+       } __attribute__ ((packed)) filelock_change;
 } __attribute__ ((packed));
 
 #define CEPH_MDS_FLAG_REPLAY        1  /* this is a replayed op */
@@ -465,6 +476,22 @@ struct ceph_mds_reply_dirfrag {
        __le32 dist[];
 } __attribute__ ((packed));
 
+#define CEPH_LOCK_FCNTL    1
+#define CEPH_LOCK_FLOCK    2
+
+#define CEPH_LOCK_SHARED   1
+#define CEPH_LOCK_EXCL     2
+#define CEPH_LOCK_UNLOCK   3
+
+struct ceph_filelock {
+       __u64 start;/* file offset to start lock at */
+       __u64 length; /* num bytes to lock; 0 for all following start */
+       __s64 client; /* which client holds the lock */
+       int pid; /* process id holding the lock on the client */
+       __u64 pid_namespace;
+       __u8 type; /* shared lock, exclusive lock, or unlock */
+} __attribute__ ((packed));
+
 /* file access modes */
 #define CEPH_FILE_MODE_PIN        0
 #define CEPH_FILE_MODE_RD         1
index 16fa711bb6aae553bfbbfe831784dbf582db37bf..bd2e10e7c9e140dc368a597c19d8073ed5f56040 100644 (file)
@@ -334,6 +334,12 @@ inline bool operator==(const byte_range_t& l, const byte_range_t& r) {
   return l.first == r.first && l.last == r.last;
 }
 
+struct ceph_lock_state_t {
+  multimap<__u64, ceph_filelock> held_locks; //current locks
+  multimap<__u64, ceph_filelock> waiting_locks; //locks waiting for other locks
+  //both of the above are keyed by starting offset
+};
+
 struct inode_t {
   // base (immutable)
   inodeno_t ino;