diff options
author | Sage Weil <sage@newdream.net> | 2010-05-25 19:46:24 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-08-01 23:11:38 -0400 |
commit | 84d9509234c46481aded977193fcf23f892d715f (patch) | |
tree | a79cdd09126323064b49ac00c2aa1a39733675d1 | |
parent | 9fe6206f400646a2322096b56c59891d530e8d51 (diff) |
ceph: request FILE_LAZYIO cap when LAZY file mode is set
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>
-rw-r--r-- | fs/ceph/ceph_fs.c | 50 | ||||
-rw-r--r-- | fs/ceph/ceph_fs.h | 3 |
2 files changed, 26 insertions, 27 deletions
diff --git a/fs/ceph/ceph_fs.c b/fs/ceph/ceph_fs.c index 79d76bc4303f..3ac6cc7c1156 100644 --- a/fs/ceph/ceph_fs.c +++ b/fs/ceph/ceph_fs.c | |||
@@ -29,46 +29,44 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) | |||
29 | 29 | ||
30 | int ceph_flags_to_mode(int flags) | 30 | int ceph_flags_to_mode(int flags) |
31 | { | 31 | { |
32 | int mode; | ||
33 | |||
32 | #ifdef O_DIRECTORY /* fixme */ | 34 | #ifdef O_DIRECTORY /* fixme */ |
33 | if ((flags & O_DIRECTORY) == O_DIRECTORY) | 35 | if ((flags & O_DIRECTORY) == O_DIRECTORY) |
34 | return CEPH_FILE_MODE_PIN; | 36 | return CEPH_FILE_MODE_PIN; |
35 | #endif | 37 | #endif |
38 | if ((flags & O_APPEND) == O_APPEND) | ||
39 | flags |= O_WRONLY; | ||
40 | |||
41 | if ((flags & O_ACCMODE) == O_RDWR) | ||
42 | mode = CEPH_FILE_MODE_RDWR; | ||
43 | else if ((flags & O_ACCMODE) == O_WRONLY) | ||
44 | mode = CEPH_FILE_MODE_WR; | ||
45 | else | ||
46 | mode = CEPH_FILE_MODE_RD; | ||
47 | |||
36 | #ifdef O_LAZY | 48 | #ifdef O_LAZY |
37 | if (flags & O_LAZY) | 49 | if (flags & O_LAZY) |
38 | return CEPH_FILE_MODE_LAZY; | 50 | mode |= CEPH_FILE_MODE_LAZY; |
39 | #endif | 51 | #endif |
40 | if ((flags & O_APPEND) == O_APPEND) | ||
41 | flags |= O_WRONLY; | ||
42 | 52 | ||
43 | flags &= O_ACCMODE; | 53 | return mode; |
44 | if ((flags & O_RDWR) == O_RDWR) | ||
45 | return CEPH_FILE_MODE_RDWR; | ||
46 | if ((flags & O_WRONLY) == O_WRONLY) | ||
47 | return CEPH_FILE_MODE_WR; | ||
48 | return CEPH_FILE_MODE_RD; | ||
49 | } | 54 | } |
50 | 55 | ||
51 | int ceph_caps_for_mode(int mode) | 56 | int ceph_caps_for_mode(int mode) |
52 | { | 57 | { |
53 | switch (mode) { | 58 | int caps = CEPH_CAP_PIN; |
54 | case CEPH_FILE_MODE_PIN: | 59 | |
55 | return CEPH_CAP_PIN; | 60 | if (mode & CEPH_FILE_MODE_RD) |
56 | case CEPH_FILE_MODE_RD: | 61 | caps |= CEPH_CAP_FILE_SHARED | |
57 | return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | | ||
58 | CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE; | 62 | CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE; |
59 | case CEPH_FILE_MODE_RDWR: | 63 | if (mode & CEPH_FILE_MODE_WR) |
60 | return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | | 64 | caps |= CEPH_CAP_FILE_EXCL | |
61 | CEPH_CAP_FILE_EXCL | | ||
62 | CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | | ||
63 | CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | | ||
64 | CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | | ||
65 | CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; | ||
66 | case CEPH_FILE_MODE_WR: | ||
67 | return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | | ||
68 | CEPH_CAP_FILE_EXCL | | ||
69 | CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | | 65 | CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | |
70 | CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | | 66 | CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | |
71 | CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; | 67 | CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; |
72 | } | 68 | if (mode & CEPH_FILE_MODE_LAZY) |
73 | return 0; | 69 | caps |= CEPH_CAP_FILE_LAZYIO; |
70 | |||
71 | return caps; | ||
74 | } | 72 | } |
diff --git a/fs/ceph/ceph_fs.h b/fs/ceph/ceph_fs.h index 2fa992eaf7da..c2e4c61a99a3 100644 --- a/fs/ceph/ceph_fs.h +++ b/fs/ceph/ceph_fs.h | |||
@@ -563,7 +563,8 @@ int ceph_flags_to_mode(int flags); | |||
563 | CEPH_CAP_FILE_EXCL) | 563 | CEPH_CAP_FILE_EXCL) |
564 | #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) | 564 | #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) |
565 | #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \ | 565 | #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \ |
566 | CEPH_CAP_ANY_FILE_WR | CEPH_CAP_PIN) | 566 | CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \ |
567 | CEPH_CAP_PIN) | ||
567 | 568 | ||
568 | #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ | 569 | #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ |
569 | CEPH_LOCK_IXATTR) | 570 | CEPH_LOCK_IXATTR) |