xfs_extfree_item.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. typedef struct xfs_extent_32 {
  33. __uint64_t ext_start;
  34. __uint32_t ext_len;
  35. } __attribute__((packed)) xfs_extent_32_t;
  36. typedef struct xfs_extent_64 {
  37. __uint64_t ext_start;
  38. __uint32_t ext_len;
  39. __uint32_t ext_pad;
  40. } xfs_extent_64_t;
  41. /*
  42. * This is the structure used to lay out an efi log item in the
  43. * log. The efi_extents field is a variable size array whose
  44. * size is given by efi_nextents.
  45. */
  46. typedef struct xfs_efi_log_format {
  47. __uint16_t efi_type; /* efi log item type */
  48. __uint16_t efi_size; /* size of this item */
  49. __uint32_t efi_nextents; /* # extents to free */
  50. __uint64_t efi_id; /* efi identifier */
  51. xfs_extent_t efi_extents[1]; /* array of extents to free */
  52. } xfs_efi_log_format_t;
  53. typedef struct xfs_efi_log_format_32 {
  54. __uint16_t efi_type; /* efi log item type */
  55. __uint16_t efi_size; /* size of this item */
  56. __uint32_t efi_nextents; /* # extents to free */
  57. __uint64_t efi_id; /* efi identifier */
  58. xfs_extent_32_t efi_extents[1]; /* array of extents to free */
  59. } __attribute__((packed)) xfs_efi_log_format_32_t;
  60. typedef struct xfs_efi_log_format_64 {
  61. __uint16_t efi_type; /* efi log item type */
  62. __uint16_t efi_size; /* size of this item */
  63. __uint32_t efi_nextents; /* # extents to free */
  64. __uint64_t efi_id; /* efi identifier */
  65. xfs_extent_64_t efi_extents[1]; /* array of extents to free */
  66. } xfs_efi_log_format_64_t;
  67. /*
  68. * This is the structure used to lay out an efd log item in the
  69. * log. The efd_extents array is a variable size array whose
  70. * size is given by efd_nextents;
  71. */
  72. typedef struct xfs_efd_log_format {
  73. __uint16_t efd_type; /* efd log item type */
  74. __uint16_t efd_size; /* size of this item */
  75. __uint32_t efd_nextents; /* # of extents freed */
  76. __uint64_t efd_efi_id; /* id of corresponding efi */
  77. xfs_extent_t efd_extents[1]; /* array of extents freed */
  78. } xfs_efd_log_format_t;
  79. typedef struct xfs_efd_log_format_32 {
  80. __uint16_t efd_type; /* efd log item type */
  81. __uint16_t efd_size; /* size of this item */
  82. __uint32_t efd_nextents; /* # of extents freed */
  83. __uint64_t efd_efi_id; /* id of corresponding efi */
  84. xfs_extent_32_t efd_extents[1]; /* array of extents freed */
  85. } __attribute__((packed)) xfs_efd_log_format_32_t;
  86. typedef struct xfs_efd_log_format_64 {
  87. __uint16_t efd_type; /* efd log item type */
  88. __uint16_t efd_size; /* size of this item */
  89. __uint32_t efd_nextents; /* # of extents freed */
  90. __uint64_t efd_efi_id; /* id of corresponding efi */
  91. xfs_extent_64_t efd_extents[1]; /* array of extents freed */
  92. } xfs_efd_log_format_64_t;
  93. #ifdef __KERNEL__
  94. /*
  95. * Max number of extents in fast allocation path.
  96. */
  97. #define XFS_EFI_MAX_FAST_EXTENTS 16
  98. /*
  99. * Define EFI flag bits. Manipulated by set/clear/test_bit operators.
  100. */
  101. #define XFS_EFI_RECOVERED 1
  102. #define XFS_EFI_COMMITTED 2
  103. /*
  104. * This is the "extent free intention" log item. It is used
  105. * to log the fact that some extents need to be free. It is
  106. * used in conjunction with the "extent free done" log item
  107. * described below.
  108. */
  109. typedef struct xfs_efi_log_item {
  110. xfs_log_item_t efi_item;
  111. atomic_t efi_next_extent;
  112. unsigned long efi_flags; /* misc flags */
  113. xfs_efi_log_format_t efi_format;
  114. } xfs_efi_log_item_t;
  115. /*
  116. * This is the "extent free done" log item. It is used to log
  117. * the fact that some extents earlier mentioned in an efi item
  118. * have been freed.
  119. */
  120. typedef struct xfs_efd_log_item {
  121. xfs_log_item_t efd_item;
  122. xfs_efi_log_item_t *efd_efip;
  123. uint efd_next_extent;
  124. xfs_efd_log_format_t efd_format;
  125. } xfs_efd_log_item_t;
  126. /*
  127. * Max number of extents in fast allocation path.
  128. */
  129. #define XFS_EFD_MAX_FAST_EXTENTS 16
  130. extern struct kmem_zone *xfs_efi_zone;
  131. extern struct kmem_zone *xfs_efd_zone;
  132. xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
  133. xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
  134. uint);
  135. int xfs_efi_copy_format(xfs_log_iovec_t *buf,
  136. xfs_efi_log_format_t *dst_efi_fmt);
  137. void xfs_efi_item_free(xfs_efi_log_item_t *);
  138. #endif /* __KERNEL__ */
  139. #endif /* __XFS_EXTFREE_ITEM_H__ */