xfs_buf_item.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_BUF_ITEM_H__
  33. #define __XFS_BUF_ITEM_H__
  34. /*
  35. * This is the structure used to lay out a buf log item in the
  36. * log. The data map describes which 128 byte chunks of the buffer
  37. * have been logged. This structure works only on buffers that
  38. * reside up to the first TB in the filesystem. These buffers are
  39. * generated only by pre-6.2 systems and are known as XFS_LI_6_1_BUF.
  40. */
  41. typedef struct xfs_buf_log_format_v1 {
  42. unsigned short blf_type; /* buf log item type indicator */
  43. unsigned short blf_size; /* size of this item */
  44. __int32_t blf_blkno; /* starting blkno of this buf */
  45. ushort blf_flags; /* misc state */
  46. ushort blf_len; /* number of blocks in this buf */
  47. unsigned int blf_map_size; /* size of data bitmap in words */
  48. unsigned int blf_data_map[1];/* variable size bitmap of */
  49. /* regions of buffer in this item */
  50. } xfs_buf_log_format_v1_t;
  51. /*
  52. * This is a form of the above structure with a 64 bit blkno field.
  53. * For 6.2 and beyond, this is XFS_LI_BUF. We use this to log everything.
  54. */
  55. typedef struct xfs_buf_log_format_t {
  56. unsigned short blf_type; /* buf log item type indicator */
  57. unsigned short blf_size; /* size of this item */
  58. ushort blf_flags; /* misc state */
  59. ushort blf_len; /* number of blocks in this buf */
  60. __int64_t blf_blkno; /* starting blkno of this buf */
  61. unsigned int blf_map_size; /* size of data bitmap in words */
  62. unsigned int blf_data_map[1];/* variable size bitmap of */
  63. /* regions of buffer in this item */
  64. } xfs_buf_log_format_t;
  65. /*
  66. * This flag indicates that the buffer contains on disk inodes
  67. * and requires special recovery handling.
  68. */
  69. #define XFS_BLI_INODE_BUF 0x1
  70. /*
  71. * This flag indicates that the buffer should not be replayed
  72. * during recovery because its blocks are being freed.
  73. */
  74. #define XFS_BLI_CANCEL 0x2
  75. /*
  76. * This flag indicates that the buffer contains on disk
  77. * user or group dquots and may require special recovery handling.
  78. */
  79. #define XFS_BLI_UDQUOT_BUF 0x4
  80. #define XFS_BLI_PDQUOT_BUF 0x8
  81. #define XFS_BLI_GDQUOT_BUF 0x10
  82. #define XFS_BLI_CHUNK 128
  83. #define XFS_BLI_SHIFT 7
  84. #define BIT_TO_WORD_SHIFT 5
  85. #define NBWORD (NBBY * sizeof(unsigned int))
  86. /*
  87. * buf log item flags
  88. */
  89. #define XFS_BLI_HOLD 0x01
  90. #define XFS_BLI_DIRTY 0x02
  91. #define XFS_BLI_STALE 0x04
  92. #define XFS_BLI_LOGGED 0x08
  93. #define XFS_BLI_INODE_ALLOC_BUF 0x10
  94. #define XFS_BLI_STALE_INODE 0x20
  95. #ifdef __KERNEL__
  96. struct xfs_buf;
  97. struct ktrace;
  98. struct xfs_mount;
  99. struct xfs_buf_log_item;
  100. #if defined(XFS_BLI_TRACE)
  101. #define XFS_BLI_TRACE_SIZE 32
  102. void xfs_buf_item_trace(char *, struct xfs_buf_log_item *);
  103. #else
  104. #define xfs_buf_item_trace(id, bip)
  105. #endif
  106. /*
  107. * This is the in core log item structure used to track information
  108. * needed to log buffers. It tracks how many times the lock has been
  109. * locked, and which 128 byte chunks of the buffer are dirty.
  110. */
  111. typedef struct xfs_buf_log_item {
  112. xfs_log_item_t bli_item; /* common item structure */
  113. struct xfs_buf *bli_buf; /* real buffer pointer */
  114. unsigned int bli_flags; /* misc flags */
  115. unsigned int bli_recur; /* lock recursion count */
  116. atomic_t bli_refcount; /* cnt of tp refs */
  117. #ifdef XFS_BLI_TRACE
  118. struct ktrace *bli_trace; /* event trace buf */
  119. #endif
  120. #ifdef XFS_TRANS_DEBUG
  121. char *bli_orig; /* original buffer copy */
  122. char *bli_logged; /* bytes logged (bitmap) */
  123. #endif
  124. xfs_buf_log_format_t bli_format; /* in-log header */
  125. } xfs_buf_log_item_t;
  126. /*
  127. * This structure is used during recovery to record the buf log
  128. * items which have been canceled and should not be replayed.
  129. */
  130. typedef struct xfs_buf_cancel {
  131. xfs_daddr_t bc_blkno;
  132. uint bc_len;
  133. int bc_refcount;
  134. struct xfs_buf_cancel *bc_next;
  135. } xfs_buf_cancel_t;
  136. void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
  137. void xfs_buf_item_relse(struct xfs_buf *);
  138. void xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
  139. uint xfs_buf_item_dirty(xfs_buf_log_item_t *);
  140. void xfs_buf_attach_iodone(struct xfs_buf *,
  141. void(*)(struct xfs_buf *, xfs_log_item_t *),
  142. xfs_log_item_t *);
  143. void xfs_buf_iodone_callbacks(struct xfs_buf *);
  144. void xfs_buf_iodone(struct xfs_buf *, xfs_buf_log_item_t *);
  145. #ifdef XFS_TRANS_DEBUG
  146. void
  147. xfs_buf_item_flush_log_debug(
  148. struct xfs_buf *bp,
  149. uint first,
  150. uint last);
  151. #else
  152. #define xfs_buf_item_flush_log_debug(bp, first, last)
  153. #endif
  154. #endif /* __KERNEL__ */
  155. #endif /* __XFS_BUF_ITEM_H__ */