xfs_extfree_item.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2000,2005 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_EXTFREE_ITEM_H__
  19. #define __XFS_EXTFREE_ITEM_H__
  20. struct xfs_mount;
  21. struct kmem_zone;
  22. typedef struct xfs_extent {
  23. xfs_dfsbno_t ext_start;
  24. xfs_extlen_t ext_len;
  25. } xfs_extent_t;
  26. /*
  27. * Since an xfs_extent_t has types (start:64, len: 32)
  28. * there are different alignments on 32 bit and 64 bit kernels.
  29. * So we provide the different variants for use by a
  30. * conversion routine.
  31. */
  32. #ifndef HAVE_FORMAT32
  33. typedef struct xfs_extent_32 {
  34. __uint64_t ext_start;
  35. __uint32_t ext_len;
  36. } __attribute__((packed)) xfs_extent_32_t;
  37. #endif
  38. typedef struct xfs_extent_64 {
  39. __uint64_t ext_start;
  40. __uint32_t ext_len;
  41. __uint32_t ext_pad;
  42. } xfs_extent_64_t;
  43. /*
  44. * This is the structure used to lay out an efi log item in the
  45. * log. The efi_extents field is a variable size array whose
  46. * size is given by efi_nextents.
  47. */
  48. typedef struct xfs_efi_log_format {
  49. __uint16_t efi_type; /* efi log item type */
  50. __uint16_t efi_size; /* size of this item */
  51. __uint32_t efi_nextents; /* # extents to free */
  52. __uint64_t efi_id; /* efi identifier */
  53. xfs_extent_t efi_extents[1]; /* array of extents to free */
  54. } xfs_efi_log_format_t;
  55. #ifndef HAVE_FORMAT32
  56. typedef struct xfs_efi_log_format_32 {
  57. __uint16_t efi_type; /* efi log item type */
  58. __uint16_t efi_size; /* size of this item */
  59. __uint32_t efi_nextents; /* # extents to free */
  60. __uint64_t efi_id; /* efi identifier */
  61. xfs_extent_32_t efi_extents[1]; /* array of extents to free */
  62. } __attribute__((packed)) xfs_efi_log_format_32_t;
  63. #endif
  64. typedef struct xfs_efi_log_format_64 {
  65. __uint16_t efi_type; /* efi log item type */
  66. __uint16_t efi_size; /* size of this item */
  67. __uint32_t efi_nextents; /* # extents to free */
  68. __uint64_t efi_id; /* efi identifier */
  69. xfs_extent_64_t efi_extents[1]; /* array of extents to free */
  70. } xfs_efi_log_format_64_t;
  71. /*
  72. * This is the structure used to lay out an efd log item in the
  73. * log. The efd_extents array is a variable size array whose
  74. * size is given by efd_nextents;
  75. */
  76. typedef struct xfs_efd_log_format {
  77. __uint16_t efd_type; /* efd log item type */
  78. __uint16_t efd_size; /* size of this item */
  79. __uint32_t efd_nextents; /* # of extents freed */
  80. __uint64_t efd_efi_id; /* id of corresponding efi */
  81. xfs_extent_t efd_extents[1]; /* array of extents freed */
  82. } xfs_efd_log_format_t;
  83. #ifndef HAVE_FORMAT32
  84. typedef struct xfs_efd_log_format_32 {
  85. __uint16_t efd_type; /* efd log item type */
  86. __uint16_t efd_size; /* size of this item */
  87. __uint32_t efd_nextents; /* # of extents freed */
  88. __uint64_t efd_efi_id; /* id of corresponding efi */
  89. xfs_extent_32_t efd_extents[1]; /* array of extents freed */
  90. } __attribute__((packed)) xfs_efd_log_format_32_t;
  91. #endif
  92. typedef struct xfs_efd_log_format_64 {
  93. __uint16_t efd_type; /* efd log item type */
  94. __uint16_t efd_size; /* size of this item */
  95. __uint32_t efd_nextents; /* # of extents freed */
  96. __uint64_t efd_efi_id; /* id of corresponding efi */
  97. xfs_extent_64_t efd_extents[1]; /* array of extents freed */
  98. } xfs_efd_log_format_64_t;
  99. #ifdef __KERNEL__
  100. /*
  101. * Max number of extents in fast allocation path.
  102. */
  103. #define XFS_EFI_MAX_FAST_EXTENTS 16
  104. /*
  105. * Define EFI flags.
  106. */
  107. #define XFS_EFI_RECOVERED 0x1
  108. #define XFS_EFI_COMMITTED 0x2
  109. #define XFS_EFI_CANCELED 0x4
  110. /*
  111. * This is the "extent free intention" log item. It is used
  112. * to log the fact that some extents need to be free. It is
  113. * used in conjunction with the "extent free done" log item
  114. * described below.
  115. */
  116. typedef struct xfs_efi_log_item {
  117. xfs_log_item_t efi_item;
  118. uint efi_flags; /* misc flags */
  119. uint efi_next_extent;
  120. xfs_efi_log_format_t efi_format;
  121. } xfs_efi_log_item_t;
  122. /*
  123. * This is the "extent free done" log item. It is used to log
  124. * the fact that some extents earlier mentioned in an efi item
  125. * have been freed.
  126. */
  127. typedef struct xfs_efd_log_item {
  128. xfs_log_item_t efd_item;
  129. xfs_efi_log_item_t *efd_efip;
  130. uint efd_next_extent;
  131. xfs_efd_log_format_t efd_format;
  132. } xfs_efd_log_item_t;
  133. /*
  134. * Max number of extents in fast allocation path.
  135. */
  136. #define XFS_EFD_MAX_FAST_EXTENTS 16
  137. extern struct kmem_zone *xfs_efi_zone;
  138. extern struct kmem_zone *xfs_efd_zone;
  139. xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
  140. xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
  141. uint);
  142. int xfs_efi_copy_format(xfs_log_iovec_t *buf,
  143. xfs_efi_log_format_t *dst_efi_fmt);
  144. void xfs_efi_item_free(xfs_efi_log_item_t *);
  145. #endif /* __KERNEL__ */
  146. #endif /* __XFS_EXTFREE_ITEM_H__ */