diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-19 12:43:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-19 12:43:06 -0400 |
commit | fc7f99cf36ebae853639dabb43bc2f0098c59aef (patch) | |
tree | 3ca7050397f515f91ef98f8b6293f9f7fd84ef02 /fs/ceph/ceph_fs.c | |
parent | 0a492fdef8aa241f6139e6455e852cc710ae8ed1 (diff) | |
parent | f1a3d57213fe264b4cf584e78bac36aaf9998729 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: (205 commits)
ceph: update for write_inode API change
ceph: reset osd after relevant messages timed out
ceph: fix flush_dirty_caps race with caps migration
ceph: include migrating caps in issued set
ceph: fix osdmap decoding when pools include (removed) snaps
ceph: return EBADF if waiting for caps on closed file
ceph: set osd request message front length correctly
ceph: reset front len on return to msgpool; BUG on mismatched front iov
ceph: fix snaptrace decoding on cap migration between mds
ceph: use single osd op reply msg
ceph: reset bits on connection close
ceph: remove bogus mds forward warning
ceph: remove fragile __map_osds optimization
ceph: fix connection fault STANDBY check
ceph: invalidate_authorizer without con->mutex held
ceph: don't clobber write return value when using O_SYNC
ceph: fix client_request_forward decoding
ceph: drop messages on unregistered mds sessions; cleanup
ceph: fix comments, locking in destroy_inode
ceph: move dereference after NULL test
...
Fix trivial conflicts in Documentation/ioctl/ioctl-number.txt
Diffstat (limited to 'fs/ceph/ceph_fs.c')
-rw-r--r-- | fs/ceph/ceph_fs.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/fs/ceph/ceph_fs.c b/fs/ceph/ceph_fs.c new file mode 100644 index 000000000000..79d76bc4303f --- /dev/null +++ b/fs/ceph/ceph_fs.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Some non-inline ceph helpers | ||
3 | */ | ||
4 | #include "types.h" | ||
5 | |||
6 | /* | ||
7 | * return true if @layout appears to be valid | ||
8 | */ | ||
9 | int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) | ||
10 | { | ||
11 | __u32 su = le32_to_cpu(layout->fl_stripe_unit); | ||
12 | __u32 sc = le32_to_cpu(layout->fl_stripe_count); | ||
13 | __u32 os = le32_to_cpu(layout->fl_object_size); | ||
14 | |||
15 | /* stripe unit, object size must be non-zero, 64k increment */ | ||
16 | if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1))) | ||
17 | return 0; | ||
18 | if (!os || (os & (CEPH_MIN_STRIPE_UNIT-1))) | ||
19 | return 0; | ||
20 | /* object size must be a multiple of stripe unit */ | ||
21 | if (os < su || os % su) | ||
22 | return 0; | ||
23 | /* stripe count must be non-zero */ | ||
24 | if (!sc) | ||
25 | return 0; | ||
26 | return 1; | ||
27 | } | ||
28 | |||
29 | |||
30 | int ceph_flags_to_mode(int flags) | ||
31 | { | ||
32 | #ifdef O_DIRECTORY /* fixme */ | ||
33 | if ((flags & O_DIRECTORY) == O_DIRECTORY) | ||
34 | return CEPH_FILE_MODE_PIN; | ||
35 | #endif | ||
36 | #ifdef O_LAZY | ||
37 | if (flags & O_LAZY) | ||
38 | return CEPH_FILE_MODE_LAZY; | ||
39 | #endif | ||
40 | if ((flags & O_APPEND) == O_APPEND) | ||
41 | flags |= O_WRONLY; | ||
42 | |||
43 | flags &= O_ACCMODE; | ||
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 | } | ||
50 | |||
51 | int ceph_caps_for_mode(int mode) | ||
52 | { | ||
53 | switch (mode) { | ||
54 | case CEPH_FILE_MODE_PIN: | ||
55 | return CEPH_CAP_PIN; | ||
56 | case CEPH_FILE_MODE_RD: | ||
57 | return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | | ||
58 | CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE; | ||
59 | case CEPH_FILE_MODE_RDWR: | ||
60 | return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED | | ||
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 | | ||
70 | CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL | | ||
71 | CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL; | ||
72 | } | ||
73 | return 0; | ||
74 | } | ||