1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_CEPH_STRIPER_H
3 #define _LINUX_CEPH_STRIPER_H
5 #include <linux/list.h>
6 #include <linux/types.h>
8 struct ceph_file_layout
;
10 void ceph_calc_file_object_mapping(struct ceph_file_layout
*l
,
12 u64
*objno
, u64
*objoff
, u32
*xlen
);
14 struct ceph_object_extent
{
15 struct list_head oe_item
;
21 static inline void ceph_object_extent_init(struct ceph_object_extent
*ex
)
23 INIT_LIST_HEAD(&ex
->oe_item
);
27 * Called for each mapped stripe unit.
29 * @bytes: number of bytes mapped, i.e. the minimum of the full length
30 * requested (file extent length) or the remainder of the stripe
31 * unit within an object
33 typedef void (*ceph_object_extent_fn_t
)(struct ceph_object_extent
*ex
,
34 u32 bytes
, void *arg
);
36 int ceph_file_to_extents(struct ceph_file_layout
*l
, u64 off
, u64 len
,
37 struct list_head
*object_extents
,
38 struct ceph_object_extent
*alloc_fn(void *arg
),
40 ceph_object_extent_fn_t action_fn
,
42 int ceph_iterate_extents(struct ceph_file_layout
*l
, u64 off
, u64 len
,
43 struct list_head
*object_extents
,
44 ceph_object_extent_fn_t action_fn
,
47 struct ceph_file_extent
{
52 static inline u64
ceph_file_extents_bytes(struct ceph_file_extent
*file_extents
,
58 for (i
= 0; i
< num_file_extents
; i
++)
59 bytes
+= file_extents
[i
].fe_len
;
64 int ceph_extent_to_file(struct ceph_file_layout
*l
,
65 u64 objno
, u64 objoff
, u64 objlen
,
66 struct ceph_file_extent
**file_extents
,
67 u32
*num_file_extents
);
69 u64
ceph_get_num_objects(struct ceph_file_layout
*l
, u64 size
);