2 * Some non-inline ceph helpers
7 * return true if @layout appears to be valid
9 int ceph_file_layout_is_valid(const struct ceph_file_layout
*layout
)
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
);
15 /* stripe unit, object size must be non-zero, 64k increment */
16 if (!su
|| (su
& (CEPH_MIN_STRIPE_UNIT
-1)))
18 if (!os
|| (os
& (CEPH_MIN_STRIPE_UNIT
-1)))
20 /* object size must be a multiple of stripe unit */
21 if (os
< su
|| os
% su
)
23 /* stripe count must be non-zero */
30 int ceph_flags_to_mode(int flags
)
32 #ifdef O_DIRECTORY /* fixme */
33 if ((flags
& O_DIRECTORY
) == O_DIRECTORY
)
34 return CEPH_FILE_MODE_PIN
;
38 return CEPH_FILE_MODE_LAZY
;
40 if ((flags
& O_APPEND
) == O_APPEND
)
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
;
51 int ceph_caps_for_mode(int mode
)
54 case CEPH_FILE_MODE_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
|
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
|
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
;