0001
0002 #ifndef _LINUX_CEPH_STRIPER_H
0003 #define _LINUX_CEPH_STRIPER_H
0004
0005 #include <linux/list.h>
0006 #include <linux/types.h>
0007
0008 struct ceph_file_layout;
0009
0010 void ceph_calc_file_object_mapping(struct ceph_file_layout *l,
0011 u64 off, u64 len,
0012 u64 *objno, u64 *objoff, u32 *xlen);
0013
0014 struct ceph_object_extent {
0015 struct list_head oe_item;
0016 u64 oe_objno;
0017 u64 oe_off;
0018 u64 oe_len;
0019 };
0020
0021 static inline void ceph_object_extent_init(struct ceph_object_extent *ex)
0022 {
0023 INIT_LIST_HEAD(&ex->oe_item);
0024 }
0025
0026
0027
0028
0029
0030
0031
0032
0033 typedef void (*ceph_object_extent_fn_t)(struct ceph_object_extent *ex,
0034 u32 bytes, void *arg);
0035
0036 int ceph_file_to_extents(struct ceph_file_layout *l, u64 off, u64 len,
0037 struct list_head *object_extents,
0038 struct ceph_object_extent *alloc_fn(void *arg),
0039 void *alloc_arg,
0040 ceph_object_extent_fn_t action_fn,
0041 void *action_arg);
0042 int ceph_iterate_extents(struct ceph_file_layout *l, u64 off, u64 len,
0043 struct list_head *object_extents,
0044 ceph_object_extent_fn_t action_fn,
0045 void *action_arg);
0046
0047 struct ceph_file_extent {
0048 u64 fe_off;
0049 u64 fe_len;
0050 };
0051
0052 static inline u64 ceph_file_extents_bytes(struct ceph_file_extent *file_extents,
0053 u32 num_file_extents)
0054 {
0055 u64 bytes = 0;
0056 u32 i;
0057
0058 for (i = 0; i < num_file_extents; i++)
0059 bytes += file_extents[i].fe_len;
0060
0061 return bytes;
0062 }
0063
0064 int ceph_extent_to_file(struct ceph_file_layout *l,
0065 u64 objno, u64 objoff, u64 objlen,
0066 struct ceph_file_extent **file_extents,
0067 u32 *num_file_extents);
0068
0069 u64 ceph_get_num_objects(struct ceph_file_layout *l, u64 size);
0070
0071 #endif