striper.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_CEPH_STRIPER_H
  3. #define _LINUX_CEPH_STRIPER_H
  4. #include <linux/list.h>
  5. #include <linux/types.h>
  6. struct ceph_file_layout;
  7. void ceph_calc_file_object_mapping(struct ceph_file_layout *l,
  8. u64 off, u64 len,
  9. u64 *objno, u64 *objoff, u32 *xlen);
  10. struct ceph_object_extent {
  11. struct list_head oe_item;
  12. u64 oe_objno;
  13. u64 oe_off;
  14. u64 oe_len;
  15. };
  16. static inline void ceph_object_extent_init(struct ceph_object_extent *ex)
  17. {
  18. INIT_LIST_HEAD(&ex->oe_item);
  19. }
  20. /*
  21. * Called for each mapped stripe unit.
  22. *
  23. * @bytes: number of bytes mapped, i.e. the minimum of the full length
  24. * requested (file extent length) or the remainder of the stripe
  25. * unit within an object
  26. */
  27. typedef void (*ceph_object_extent_fn_t)(struct ceph_object_extent *ex,
  28. u32 bytes, void *arg);
  29. int ceph_file_to_extents(struct ceph_file_layout *l, u64 off, u64 len,
  30. struct list_head *object_extents,
  31. struct ceph_object_extent *alloc_fn(void *arg),
  32. void *alloc_arg,
  33. ceph_object_extent_fn_t action_fn,
  34. void *action_arg);
  35. int ceph_iterate_extents(struct ceph_file_layout *l, u64 off, u64 len,
  36. struct list_head *object_extents,
  37. ceph_object_extent_fn_t action_fn,
  38. void *action_arg);
  39. struct ceph_file_extent {
  40. u64 fe_off;
  41. u64 fe_len;
  42. };
  43. static inline u64 ceph_file_extents_bytes(struct ceph_file_extent *file_extents,
  44. u32 num_file_extents)
  45. {
  46. u64 bytes = 0;
  47. u32 i;
  48. for (i = 0; i < num_file_extents; i++)
  49. bytes += file_extents[i].fe_len;
  50. return bytes;
  51. }
  52. int ceph_extent_to_file(struct ceph_file_layout *l,
  53. u64 objno, u64 objoff, u64 objlen,
  54. struct ceph_file_extent **file_extents,
  55. u32 *num_file_extents);
  56. u64 ceph_get_num_objects(struct ceph_file_layout *l, u64 size);
  57. #endif