xfs_inode_item.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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_INODE_ITEM_H__
  19. #define __XFS_INODE_ITEM_H__
  20. /*
  21. * This is the structure used to lay out an inode log item in the
  22. * log. The size of the inline data/extents/b-tree root to be logged
  23. * (if any) is indicated in the ilf_dsize field. Changes to this structure
  24. * must be added on to the end.
  25. */
  26. typedef struct xfs_inode_log_format {
  27. __uint16_t ilf_type; /* inode log item type */
  28. __uint16_t ilf_size; /* size of this item */
  29. __uint32_t ilf_fields; /* flags for fields logged */
  30. __uint16_t ilf_asize; /* size of attr d/ext/root */
  31. __uint16_t ilf_dsize; /* size of data/ext/root */
  32. __uint64_t ilf_ino; /* inode number */
  33. union {
  34. __uint32_t ilfu_rdev; /* rdev value for dev inode*/
  35. uuid_t ilfu_uuid; /* mount point value */
  36. } ilf_u;
  37. __int64_t ilf_blkno; /* blkno of inode buffer */
  38. __int32_t ilf_len; /* len of inode buffer */
  39. __int32_t ilf_boffset; /* off of inode in buffer */
  40. } xfs_inode_log_format_t;
  41. #ifndef HAVE_FORMAT32
  42. typedef struct xfs_inode_log_format_32 {
  43. __uint16_t ilf_type; /* inode log item type */
  44. __uint16_t ilf_size; /* size of this item */
  45. __uint32_t ilf_fields; /* flags for fields logged */
  46. __uint16_t ilf_asize; /* size of attr d/ext/root */
  47. __uint16_t ilf_dsize; /* size of data/ext/root */
  48. __uint64_t ilf_ino; /* inode number */
  49. union {
  50. __uint32_t ilfu_rdev; /* rdev value for dev inode*/
  51. uuid_t ilfu_uuid; /* mount point value */
  52. } ilf_u;
  53. __int64_t ilf_blkno; /* blkno of inode buffer */
  54. __int32_t ilf_len; /* len of inode buffer */
  55. __int32_t ilf_boffset; /* off of inode in buffer */
  56. } __attribute__((packed)) xfs_inode_log_format_32_t;
  57. #endif
  58. typedef struct xfs_inode_log_format_64 {
  59. __uint16_t ilf_type; /* inode log item type */
  60. __uint16_t ilf_size; /* size of this item */
  61. __uint32_t ilf_fields; /* flags for fields logged */
  62. __uint16_t ilf_asize; /* size of attr d/ext/root */
  63. __uint16_t ilf_dsize; /* size of data/ext/root */
  64. __uint32_t ilf_pad; /* pad for 64 bit boundary */
  65. __uint64_t ilf_ino; /* inode number */
  66. union {
  67. __uint32_t ilfu_rdev; /* rdev value for dev inode*/
  68. uuid_t ilfu_uuid; /* mount point value */
  69. } ilf_u;
  70. __int64_t ilf_blkno; /* blkno of inode buffer */
  71. __int32_t ilf_len; /* len of inode buffer */
  72. __int32_t ilf_boffset; /* off of inode in buffer */
  73. } xfs_inode_log_format_64_t;
  74. /*
  75. * Flags for xfs_trans_log_inode flags field.
  76. */
  77. #define XFS_ILOG_CORE 0x001 /* log standard inode fields */
  78. #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
  79. #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
  80. #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
  81. #define XFS_ILOG_DEV 0x010 /* log the dev field */
  82. #define XFS_ILOG_UUID 0x020 /* log the uuid field */
  83. #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
  84. #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
  85. #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
  86. #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
  87. XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
  88. XFS_ILOG_UUID | XFS_ILOG_ADATA | \
  89. XFS_ILOG_AEXT | XFS_ILOG_ABROOT)
  90. #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
  91. XFS_ILOG_DBROOT)
  92. #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
  93. XFS_ILOG_ABROOT)
  94. #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
  95. XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
  96. XFS_ILOG_DEV | XFS_ILOG_UUID | \
  97. XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
  98. XFS_ILOG_ABROOT)
  99. #define XFS_ILI_HOLD 0x1
  100. #define XFS_ILI_IOLOCKED_EXCL 0x2
  101. #define XFS_ILI_IOLOCKED_SHARED 0x4
  102. #define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)
  103. static inline int xfs_ilog_fbroot(int w)
  104. {
  105. return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
  106. }
  107. static inline int xfs_ilog_fext(int w)
  108. {
  109. return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
  110. }
  111. static inline int xfs_ilog_fdata(int w)
  112. {
  113. return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
  114. }
  115. #ifdef __KERNEL__
  116. struct xfs_buf;
  117. struct xfs_bmbt_rec_64;
  118. struct xfs_inode;
  119. struct xfs_mount;
  120. typedef struct xfs_inode_log_item {
  121. xfs_log_item_t ili_item; /* common portion */
  122. struct xfs_inode *ili_inode; /* inode ptr */
  123. xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
  124. xfs_lsn_t ili_last_lsn; /* lsn at last transaction */
  125. unsigned short ili_ilock_recur; /* lock recursion count */
  126. unsigned short ili_iolock_recur; /* lock recursion count */
  127. unsigned short ili_flags; /* misc flags */
  128. unsigned short ili_logged; /* flushed logged data */
  129. unsigned int ili_last_fields; /* fields when flushed */
  130. struct xfs_bmbt_rec_64 *ili_extents_buf; /* array of logged
  131. data exts */
  132. struct xfs_bmbt_rec_64 *ili_aextents_buf; /* array of logged
  133. attr exts */
  134. unsigned int ili_pushbuf_flag; /* one bit used in push_ail */
  135. #ifdef DEBUG
  136. uint64_t ili_push_owner; /* one who sets pushbuf_flag
  137. above gets to push the buf */
  138. #endif
  139. #ifdef XFS_TRANS_DEBUG
  140. int ili_root_size;
  141. char *ili_orig_root;
  142. #endif
  143. xfs_inode_log_format_t ili_format; /* logged structure */
  144. } xfs_inode_log_item_t;
  145. static inline int xfs_inode_clean(xfs_inode_t *ip)
  146. {
  147. return (!ip->i_itemp ||
  148. !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) &&
  149. !ip->i_update_core;
  150. }
  151. extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
  152. extern void xfs_inode_item_destroy(struct xfs_inode *);
  153. extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *);
  154. extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *);
  155. extern void xfs_iflush_abort(struct xfs_inode *);
  156. extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
  157. xfs_inode_log_format_t *);
  158. #endif /* __KERNEL__ */
  159. #endif /* __XFS_INODE_ITEM_H__ */