aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Farnum <gregf@hq.newdream.net>2010-08-02 18:30:08 -0400
committerSage Weil <sage@newdream.net>2010-08-02 18:48:54 -0400
commitfbaad9797a761c2d5ff6e755bbb4c046207a1ca2 (patch)
treeabe5e3668294922e70282dab9c36072cac1939c9
parentc6f3fdc592d61847da0e2172e352dbcb53c83d39 (diff)
ceph: define on-wire types, constants for file locking support
Define the MDS operations and data types for doing file advisory locking with the MDS. Signed-off-by: Greg Farnum <gregf@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r--fs/ceph/ceph_fs.h36
-rw-r--r--fs/ceph/ceph_strings.c2
2 files changed, 36 insertions, 2 deletions
diff --git a/fs/ceph/ceph_fs.h b/fs/ceph/ceph_fs.h
index bb17a18cc190..d5619ac86711 100644
--- a/fs/ceph/ceph_fs.h
+++ b/fs/ceph/ceph_fs.h
@@ -297,6 +297,8 @@ enum {
297 CEPH_MDS_OP_RMXATTR = 0x01106, 297 CEPH_MDS_OP_RMXATTR = 0x01106,
298 CEPH_MDS_OP_SETLAYOUT = 0x01107, 298 CEPH_MDS_OP_SETLAYOUT = 0x01107,
299 CEPH_MDS_OP_SETATTR = 0x01108, 299 CEPH_MDS_OP_SETATTR = 0x01108,
300 CEPH_MDS_OP_SETFILELOCK= 0x01109,
301 CEPH_MDS_OP_GETFILELOCK= 0x00110,
300 302
301 CEPH_MDS_OP_MKNOD = 0x01201, 303 CEPH_MDS_OP_MKNOD = 0x01201,
302 CEPH_MDS_OP_LINK = 0x01202, 304 CEPH_MDS_OP_LINK = 0x01202,
@@ -367,6 +369,15 @@ union ceph_mds_request_args {
367 struct { 369 struct {
368 struct ceph_file_layout layout; 370 struct ceph_file_layout layout;
369 } __attribute__ ((packed)) setlayout; 371 } __attribute__ ((packed)) setlayout;
372 struct {
373 __u8 rule; /* currently fcntl or flock */
374 __u8 type; /* shared, exclusive, remove*/
375 __le64 pid; /* process id requesting the lock */
376 __le64 pid_namespace;
377 __le64 start; /* initial location to lock */
378 __le64 length; /* num bytes to lock from start */
379 __u8 wait; /* will caller wait for lock to become available? */
380 } __attribute__ ((packed)) filelock_change;
370} __attribute__ ((packed)); 381} __attribute__ ((packed));
371 382
372#define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */ 383#define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
@@ -461,6 +472,23 @@ struct ceph_mds_reply_dirfrag {
461 __le32 dist[]; 472 __le32 dist[];
462} __attribute__ ((packed)); 473} __attribute__ ((packed));
463 474
475#define CEPH_LOCK_FCNTL 1
476#define CEPH_LOCK_FLOCK 2
477
478#define CEPH_LOCK_SHARED 1
479#define CEPH_LOCK_EXCL 2
480#define CEPH_LOCK_UNLOCK 4
481
482struct ceph_filelock {
483 __le64 start;/* file offset to start lock at */
484 __le64 length; /* num bytes to lock; 0 for all following start */
485 __le64 client; /* which client holds the lock */
486 __le64 pid; /* process id holding the lock on the client */
487 __le64 pid_namespace;
488 __u8 type; /* shared lock, exclusive lock, or unlock */
489} __attribute__ ((packed));
490
491
464/* file access modes */ 492/* file access modes */
465#define CEPH_FILE_MODE_PIN 0 493#define CEPH_FILE_MODE_PIN 0
466#define CEPH_FILE_MODE_RD 1 494#define CEPH_FILE_MODE_RD 1
@@ -489,9 +517,10 @@ int ceph_flags_to_mode(int flags);
489#define CEPH_CAP_SAUTH 2 517#define CEPH_CAP_SAUTH 2
490#define CEPH_CAP_SLINK 4 518#define CEPH_CAP_SLINK 4
491#define CEPH_CAP_SXATTR 6 519#define CEPH_CAP_SXATTR 6
492#define CEPH_CAP_SFILE 8 /* goes at the end (uses >2 cap bits) */ 520#define CEPH_CAP_SFILE 8
521#define CEPH_CAP_SFLOCK 20
493 522
494#define CEPH_CAP_BITS 16 523#define CEPH_CAP_BITS 22
495 524
496/* composed values */ 525/* composed values */
497#define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH) 526#define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
@@ -509,6 +538,9 @@ int ceph_flags_to_mode(int flags);
509#define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE) 538#define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
510#define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE) 539#define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
511#define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE) 540#define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
541#define CEPH_CAP_FLOCK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFLOCK)
542#define CEPH_CAP_FLOCK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFLOCK)
543
512 544
513/* cap masks (for getattr) */ 545/* cap masks (for getattr) */
514#define CEPH_STAT_CAP_INODE CEPH_CAP_PIN 546#define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
diff --git a/fs/ceph/ceph_strings.c b/fs/ceph/ceph_strings.c
index 0f943a0a3b5e..c6179d3a26a2 100644
--- a/fs/ceph/ceph_strings.c
+++ b/fs/ceph/ceph_strings.c
@@ -130,6 +130,8 @@ const char *ceph_mds_op_name(int op)
130 case CEPH_MDS_OP_LSSNAP: return "lssnap"; 130 case CEPH_MDS_OP_LSSNAP: return "lssnap";
131 case CEPH_MDS_OP_MKSNAP: return "mksnap"; 131 case CEPH_MDS_OP_MKSNAP: return "mksnap";
132 case CEPH_MDS_OP_RMSNAP: return "rmsnap"; 132 case CEPH_MDS_OP_RMSNAP: return "rmsnap";
133 case CEPH_MDS_OP_SETFILELOCK: return "setfilelock";
134 case CEPH_MDS_OP_GETFILELOCK: return "getfilelock";
133 } 135 }
134 return "???"; 136 return "???";
135} 137}