xfs_bmap_util.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_bmap_free_item;
  23. struct xfs_ifork;
  24. struct xfs_inode;
  25. struct xfs_mount;
  26. struct xfs_trans;
  27. /*
  28. * Argument structure for xfs_bmap_alloc.
  29. */
  30. struct xfs_bmalloca {
  31. xfs_fsblock_t *firstblock; /* i/o first block allocated */
  32. struct xfs_bmap_free *flist; /* bmap freelist */
  33. struct xfs_trans *tp; /* transaction pointer */
  34. struct xfs_inode *ip; /* incore inode pointer */
  35. struct xfs_bmbt_irec prev; /* extent before the new one */
  36. struct xfs_bmbt_irec got; /* extent after, or delayed */
  37. xfs_fileoff_t offset; /* offset in file filling in */
  38. xfs_extlen_t length; /* i/o length asked/allocated */
  39. xfs_fsblock_t blkno; /* starting block of new extent */
  40. struct xfs_btree_cur *cur; /* btree cursor */
  41. xfs_extnum_t idx; /* current extent index */
  42. int nallocs;/* number of extents alloc'd */
  43. int logflags;/* flags for transaction logging */
  44. xfs_extlen_t total; /* total blocks needed for xaction */
  45. xfs_extlen_t minlen; /* minimum allocation size (blocks) */
  46. xfs_extlen_t minleft; /* amount must be left after alloc */
  47. char eof; /* set if allocating past last extent */
  48. char wasdel; /* replacing a delayed allocation */
  49. char userdata;/* set if is user data */
  50. char aeof; /* allocated space at eof */
  51. char conv; /* overwriting unwritten extents */
  52. char stack_switch;
  53. int flags;
  54. struct completion *done;
  55. struct work_struct work;
  56. int result;
  57. };
  58. int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist,
  59. int *committed);
  60. int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
  61. int xfs_bmapi_allocate(struct xfs_bmalloca *args);
  62. int __xfs_bmapi_allocate(struct xfs_bmalloca *args);
  63. int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
  64. int whichfork, int *eof);
  65. int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
  66. int whichfork, int *count);
  67. int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
  68. xfs_fileoff_t start_fsb, xfs_fileoff_t length);
  69. /* bmap to userspace formatter - copy to user & advance pointer */
  70. typedef int (*xfs_bmap_format_t)(void **, struct getbmapx *, int *);
  71. int xfs_getbmap(struct xfs_inode *ip, struct getbmapx *bmv,
  72. xfs_bmap_format_t formatter, void *arg);
  73. /* functions in xfs_bmap.c that are only needed by xfs_bmap_util.c */
  74. void xfs_bmap_del_free(struct xfs_bmap_free *flist,
  75. struct xfs_bmap_free_item *prev,
  76. struct xfs_bmap_free_item *free);
  77. int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp,
  78. struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz,
  79. int rt, int eof, int delay, int convert,
  80. xfs_fileoff_t *offp, xfs_extlen_t *lenp);
  81. void xfs_bmap_adjacent(struct xfs_bmalloca *ap);
  82. int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
  83. int whichfork, struct xfs_bmbt_irec *rec,
  84. int *is_empty);
  85. /* preallocation and hole punch interface */
  86. int xfs_change_file_space(struct xfs_inode *ip, int cmd,
  87. xfs_flock64_t *bf, xfs_off_t offset,
  88. int attr_flags);
  89. /* EOF block manipulation functions */
  90. bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force);
  91. int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
  92. bool need_iolock);
  93. int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
  94. struct xfs_swapext *sx);
  95. xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
  96. #endif /* __XFS_BMAP_UTIL_H__ */