]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ceph: request FILE_LAZYIO cap when LAZY file mode is set
authorSage Weil <sage@newdream.net>
Tue, 25 May 2010 23:46:24 +0000 (16:46 -0700)
committerSage Weil <sage@newdream.net>
Mon, 2 Aug 2010 03:11:38 +0000 (20:11 -0700)
Also clean up the file flags -> file mode -> wanted caps functions while
we're at it.  This resyncs this file with userspace.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/ceph_fs.c
fs/ceph/ceph_fs.h

index 79d76bc4303ff7a9ce822df4b2ac24f1a6cd9604..3ac6cc7c1156dafd78262e7290edf914c3f01e31 100644 (file)
@@ -29,46 +29,44 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
 
 int ceph_flags_to_mode(int flags)
 {
+       int mode;
+
 #ifdef O_DIRECTORY  /* fixme */
        if ((flags & O_DIRECTORY) == O_DIRECTORY)
                return CEPH_FILE_MODE_PIN;
 #endif
+       if ((flags & O_APPEND) == O_APPEND)
+               flags |= O_WRONLY;
+
+       if ((flags & O_ACCMODE) == O_RDWR)
+               mode = CEPH_FILE_MODE_RDWR;
+       else if ((flags & O_ACCMODE) == O_WRONLY)
+               mode = CEPH_FILE_MODE_WR;
+       else
+               mode = CEPH_FILE_MODE_RD;
+
 #ifdef O_LAZY
        if (flags & O_LAZY)
-               return CEPH_FILE_MODE_LAZY;
+               mode |= CEPH_FILE_MODE_LAZY;
 #endif
-       if ((flags & O_APPEND) == O_APPEND)
-               flags |= O_WRONLY;
 
-       flags &= O_ACCMODE;
-       if ((flags & O_RDWR) == O_RDWR)
-               return CEPH_FILE_MODE_RDWR;
-       if ((flags & O_WRONLY) == O_WRONLY)
-               return CEPH_FILE_MODE_WR;
-       return CEPH_FILE_MODE_RD;
+       return mode;
 }
 
 int ceph_caps_for_mode(int mode)
 {
-       switch (mode) {
-       case CEPH_FILE_MODE_PIN:
-               return CEPH_CAP_PIN;
-       case CEPH_FILE_MODE_RD:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+       int caps = CEPH_CAP_PIN;
+
+       if (mode & CEPH_FILE_MODE_RD)
+               caps |= CEPH_CAP_FILE_SHARED |
                        CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE;
-       case CEPH_FILE_MODE_RDWR:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
-                       CEPH_CAP_FILE_EXCL |
-                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE |
-                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
-                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
-                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
-       case CEPH_FILE_MODE_WR:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
-                       CEPH_CAP_FILE_EXCL |
+       if (mode & CEPH_FILE_MODE_WR)
+               caps |= CEPH_CAP_FILE_EXCL |
                        CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
                        CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
                        CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
-       }
-       return 0;
+       if (mode & CEPH_FILE_MODE_LAZY)
+               caps |= CEPH_CAP_FILE_LAZYIO;
+
+       return caps;
 }
index 2fa992eaf7daae57217ab5e7f8b2f228299fc101..c2e4c61a99a306ff8990922e00e186f2a7b100ce 100644 (file)
@@ -563,7 +563,8 @@ int ceph_flags_to_mode(int flags);
                              CEPH_CAP_FILE_EXCL)
 #define CEPH_CAP_ANY_WR   (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
 #define CEPH_CAP_ANY      (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
-                          CEPH_CAP_ANY_FILE_WR | CEPH_CAP_PIN)
+                          CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
+                          CEPH_CAP_PIN)
 
 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
                        CEPH_LOCK_IXATTR)