xfs_bmap_util.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_BMAP_UTIL_H__
  19. #define __XFS_BMAP_UTIL_H__
  20. /* Kernel only BMAP related definitions and functions */
  21. struct xfs_bmbt_irec;
  22. struct xfs_extent_free_item;
  23. struct xfs_ifork;
  24. struct xfs_inode;
  25. struct xfs_mount;
  26. struct xfs_trans;
  27. struct xfs_bmalloca;
  28. #ifdef CONFIG_XFS_RT
  29. int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
  30. #else /* !CONFIG_XFS_RT */
  31. /*
  32. * Attempts to allocate RT extents when RT is disable indicates corruption and
  33. * should trigger a shutdown.
  34. */
  35. static inline int
  36. xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
  37. {
  38. return -EFSCORRUPTED;
  39. }
  40. #endif /* CONFIG_XFS_RT */
  41. int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
  42. int whichfork, int *eof);
  43. int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
  44. xfs_fileoff_t start_fsb, xfs_fileoff_t length);
  45. /* bmap to userspace formatter - copy to user & advance pointer */
  46. typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *);
  47. int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
  48. xfs_bmap_format_t formatter, void *arg);
  49. /* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
  50. int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
  51. struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
  52. int rt, int eof, int delay, int convert,
  53. xfs_fileoff_t *offp, xfs_extlen_t *lenp);
  54. void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
  55. int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
  56. int whichfork, struct xfs_bmbt_irec *rec,
  57. int *is_empty);
  58. /* preallocation and hole punch interface */
  59. int xfs_alloc_file_space(struct xfs_inode *ip, xfs_off_t offset,
  60. xfs_off_t len, int alloc_type);
  61. int xfs_free_file_space(struct xfs_inode *ip, xfs_off_t offset,
  62. xfs_off_t len);
  63. int xfs_zero_file_space(struct xfs_inode *ip, xfs_off_t offset,
  64. xfs_off_t len);
  65. int xfs_collapse_file_space(struct xfs_inode *, xfs_off_t offset,
  66. xfs_off_t len);
  67. int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset,
  68. xfs_off_t len);
  69. /* EOF block manipulation functions */
  70. bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
  71. int xfs_free_eofblocks(struct xfs_inode *ip);
  72. int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
  73. struct xfs_swapext *sx);
  74. xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
  75. #endif /* __XFS_BMAP_UTIL_H__ */