xfs_inode_item.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. typedef struct xfs_inode_log_format_32 {
  42. __uint16_t ilf_type; /* inode log item type */
  43. __uint16_t ilf_size; /* size of this item */
  44. __uint32_t ilf_fields; /* flags for fields logged */
  45. __uint16_t ilf_asize; /* size of attr d/ext/root */
  46. __uint16_t ilf_dsize; /* size of data/ext/root */
  47. __uint64_t ilf_ino; /* inode number */
  48. union {
  49. __uint32_t ilfu_rdev; /* rdev value for dev inode*/
  50. uuid_t ilfu_uuid; /* mount point value */
  51. } ilf_u;
  52. __int64_t ilf_blkno; /* blkno of inode buffer */
  53. __int32_t ilf_len; /* len of inode buffer */
  54. __int32_t ilf_boffset; /* off of inode in buffer */
  55. } __attribute__((packed)) xfs_inode_log_format_32_t;
  56. typedef struct xfs_inode_log_format_64 {
  57. __uint16_t ilf_type; /* inode log item type */
  58. __uint16_t ilf_size; /* size of this item */
  59. __uint32_t ilf_fields; /* flags for fields logged */
  60. __uint16_t ilf_asize; /* size of attr d/ext/root */
  61. __uint16_t ilf_dsize; /* size of data/ext/root */
  62. __uint32_t ilf_pad; /* pad for 64 bit boundary */
  63. __uint64_t ilf_ino; /* inode number */
  64. union {
  65. __uint32_t ilfu_rdev; /* rdev value for dev inode*/
  66. uuid_t ilfu_uuid; /* mount point value */
  67. } ilf_u;
  68. __int64_t ilf_blkno; /* blkno of inode buffer */
  69. __int32_t ilf_len; /* len of inode buffer */
  70. __int32_t ilf_boffset; /* off of inode in buffer */
  71. } xfs_inode_log_format_64_t;
  72. /*
  73. * Flags for xfs_trans_log_inode flags field.
  74. */
  75. #define XFS_ILOG_CORE 0x001 /* log standard inode fields */
  76. #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
  77. #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
  78. #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
  79. #define XFS_ILOG_DEV 0x010 /* log the dev field */
  80. #define XFS_ILOG_UUID 0x020 /* log the uuid field */
  81. #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
  82. #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
  83. #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
  84. #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
  85. XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
  86. XFS_ILOG_UUID | XFS_ILOG_ADATA | \
  87. XFS_ILOG_AEXT | XFS_ILOG_ABROOT)
  88. #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
  89. XFS_ILOG_DBROOT)
  90. #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
  91. XFS_ILOG_ABROOT)
  92. #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
  93. XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
  94. XFS_ILOG_DEV | XFS_ILOG_UUID | \
  95. XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
  96. XFS_ILOG_ABROOT)
  97. static inline int xfs_ilog_fbroot(int w)
  98. {
  99. return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
  100. }
  101. static inline int xfs_ilog_fext(int w)
  102. {
  103. return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
  104. }
  105. static inline int xfs_ilog_fdata(int w)
  106. {
  107. return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
  108. }
  109. #ifdef __KERNEL__
  110. struct xfs_buf;
  111. struct xfs_bmbt_rec;
  112. struct xfs_inode;
  113. struct xfs_mount;
  114. typedef struct xfs_inode_log_item {
  115. xfs_log_item_t ili_item; /* common portion */
  116. struct xfs_inode *ili_inode; /* inode ptr */
  117. xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
  118. xfs_lsn_t ili_last_lsn; /* lsn at last transaction */
  119. unsigned short ili_lock_flags; /* lock flags */
  120. unsigned short ili_logged; /* flushed logged data */
  121. unsigned int ili_last_fields; /* fields when flushed */
  122. struct xfs_bmbt_rec *ili_extents_buf; /* array of logged
  123. data exts */
  124. struct xfs_bmbt_rec *ili_aextents_buf; /* array of logged
  125. attr exts */
  126. #ifdef XFS_TRANS_DEBUG
  127. int ili_root_size;
  128. char *ili_orig_root;
  129. #endif
  130. xfs_inode_log_format_t ili_format; /* logged structure */
  131. } xfs_inode_log_item_t;
  132. static inline int xfs_inode_clean(xfs_inode_t *ip)
  133. {
  134. return (!ip->i_itemp ||
  135. !(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) &&
  136. !ip->i_update_core;
  137. }
  138. extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
  139. extern void xfs_inode_item_destroy(struct xfs_inode *);
  140. extern void xfs_iflush_done(struct xfs_buf *, struct xfs_log_item *);
  141. extern void xfs_istale_done(struct xfs_buf *, struct xfs_log_item *);
  142. extern void xfs_iflush_abort(struct xfs_inode *);
  143. extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
  144. xfs_inode_log_format_t *);
  145. #endif /* __KERNEL__ */
  146. #endif /* __XFS_INODE_ITEM_H__ */