extent_map.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * extent_map.h
  4. *
  5. * In-memory file extent mappings for OCFS2.
  6. *
  7. * Copyright (C) 2004 Oracle. All rights reserved.
  8. */
  9. #ifndef _EXTENT_MAP_H
  10. #define _EXTENT_MAP_H
  11. struct ocfs2_extent_map_item {
  12. unsigned int ei_cpos;
  13. unsigned int ei_phys;
  14. unsigned int ei_clusters;
  15. unsigned int ei_flags;
  16. struct list_head ei_list;
  17. };
  18. #define OCFS2_MAX_EXTENT_MAP_ITEMS 3
  19. struct ocfs2_extent_map {
  20. unsigned int em_num_items;
  21. struct list_head em_list;
  22. };
  23. void ocfs2_extent_map_init(struct inode *inode);
  24. void ocfs2_extent_map_trunc(struct inode *inode, unsigned int cluster);
  25. void ocfs2_extent_map_insert_rec(struct inode *inode,
  26. struct ocfs2_extent_rec *rec);
  27. int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster,
  28. u32 *num_clusters, unsigned int *extent_flags);
  29. int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno,
  30. u64 *ret_count, unsigned int *extent_flags);
  31. int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  32. u64 map_start, u64 map_len);
  33. int ocfs2_overwrite_io(struct inode *inode, struct buffer_head *di_bh,
  34. u64 map_start, u64 map_len);
  35. int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin);
  36. int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
  37. u32 *p_cluster, u32 *num_clusters,
  38. struct ocfs2_extent_list *el,
  39. unsigned int *extent_flags);
  40. int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
  41. struct buffer_head *bhs[], int flags,
  42. int (*validate)(struct super_block *sb,
  43. struct buffer_head *bh));
  44. int ocfs2_figure_hole_clusters(struct ocfs2_caching_info *ci,
  45. struct ocfs2_extent_list *el,
  46. struct buffer_head *eb_bh,
  47. u32 v_cluster,
  48. u32 *num_clusters);
  49. static inline int ocfs2_read_virt_block(struct inode *inode, u64 v_block,
  50. struct buffer_head **bh,
  51. int (*validate)(struct super_block *sb,
  52. struct buffer_head *bh))
  53. {
  54. int status = 0;
  55. if (bh == NULL) {
  56. printk("ocfs2: bh == NULL\n");
  57. status = -EINVAL;
  58. goto bail;
  59. }
  60. status = ocfs2_read_virt_blocks(inode, v_block, 1, bh, 0, validate);
  61. bail:
  62. return status;
  63. }
  64. #endif /* _EXTENT_MAP_H */