xfs_bmap_util.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_BMAP_UTIL_H__
  7. #define __XFS_BMAP_UTIL_H__
  8. /* Kernel only BMAP related definitions and functions */
  9. struct xfs_bmbt_irec;
  10. struct xfs_extent_free_item;
  11. struct xfs_ifork;
  12. struct xfs_inode;
  13. struct xfs_mount;
  14. struct xfs_trans;
  15. struct xfs_bmalloca;
  16. #ifdef CONFIG_XFS_RT
  17. int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
  18. #else /* !CONFIG_XFS_RT */
  19. /*
  20. * Attempts to allocate RT extents when RT is disable indicates corruption and
  21. * should trigger a shutdown.
  22. */
  23. static inline int
  24. xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
  25. {
  26. return -EFSCORRUPTED;
  27. }
  28. #endif /* CONFIG_XFS_RT */
  29. int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
  30. int whichfork, int *eof);
  31. int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
  32. xfs_fileoff_t start_fsb, xfs_fileoff_t length);
  33. struct kgetbmap {
  34. __s64 bmv_offset; /* file offset of segment in blocks */
  35. __s64 bmv_block; /* starting block (64-bit daddr_t) */
  36. __s64 bmv_length; /* length of segment, blocks */
  37. __s32 bmv_oflags; /* output flags */
  38. };
  39. int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
  40. struct kgetbmap *out);
  41. /* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
  42. int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
  43. struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
  44. int rt, int eof, int delay, int convert,
  45. xfs_fileoff_t *offp, xfs_extlen_t *lenp);
  46. void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
  47. int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
  48. int whichfork, struct xfs_bmbt_irec *rec,
  49. int *is_empty);
  50. /* preallocation and hole punch interface */
  51. int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
  52. xfs_off_t len, int alloc_type);
  53. int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
  54. xfs_off_t len);
  55. int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset,
  56. xfs_off_t len);
  57. int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
  58. xfs_off_t len);
  59. int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
  60. xfs_off_t len);
  61. /* EOF block manipulation functions */
  62. bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
  63. int xfs_free_eofblocks(struct xfs_inode *ip);
  64. int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
  65. struct xfs_swapext *sx);
  66. xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
  67. xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
  68. int xfs_flush_unmap_range(struct xfs_inode *ip, xfs_off_t offset,
  69. xfs_off_t len);
  70. int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
  71. int whichfork, xfs_extnum_t *nextents,
  72. xfs_filblks_t *count);
  73. #endif /* __XFS_BMAP_UTIL_H__ */