xfs_format.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_FORMAT_H__
  19. #define __XFS_FORMAT_H__
  20. /*
  21. * XFS On Disk Format Definitions
  22. *
  23. * This header file defines all the on-disk format definitions for
  24. * general XFS objects. Directory and attribute related objects are defined in
  25. * xfs_da_format.h, which log and log item formats are defined in
  26. * xfs_log_format.h. Everything else goes here.
  27. */
  28. struct xfs_mount;
  29. struct xfs_trans;
  30. struct xfs_inode;
  31. struct xfs_buf;
  32. struct xfs_ifork;
  33. /*
  34. * RealTime Device format definitions
  35. */
  36. /* Min and max rt extent sizes, specified in bytes */
  37. #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */
  38. #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64kB */
  39. #define XFS_MIN_RTEXTSIZE (4 * 1024) /* 4kB */
  40. #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
  41. #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
  42. #define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
  43. #define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
  44. /*
  45. * RT Summary and bit manipulation macros.
  46. */
  47. #define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
  48. #define XFS_SUMOFFSTOBLOCK(mp,s) \
  49. (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
  50. #define XFS_SUMPTR(mp,bp,so) \
  51. ((xfs_suminfo_t *)((bp)->b_addr + \
  52. (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
  53. #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
  54. #define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
  55. #define XFS_BITTOWORD(mp,bi) \
  56. ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
  57. #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
  58. #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
  59. #define XFS_RTLOBIT(w) xfs_lowbit32(w)
  60. #define XFS_RTHIBIT(w) xfs_highbit32(w)
  61. #if XFS_BIG_BLKNOS
  62. #define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
  63. #else
  64. #define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
  65. #endif
  66. /*
  67. * Dquot and dquot block format definitions
  68. */
  69. #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */
  70. #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */
  71. /*
  72. * This is the main portion of the on-disk representation of quota
  73. * information for a user. This is the q_core of the xfs_dquot_t that
  74. * is kept in kernel memory. We pad this with some more expansion room
  75. * to construct the on disk structure.
  76. */
  77. typedef struct xfs_disk_dquot {
  78. __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */
  79. __u8 d_version; /* dquot version */
  80. __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */
  81. __be32 d_id; /* user,project,group id */
  82. __be64 d_blk_hardlimit;/* absolute limit on disk blks */
  83. __be64 d_blk_softlimit;/* preferred limit on disk blks */
  84. __be64 d_ino_hardlimit;/* maximum # allocated inodes */
  85. __be64 d_ino_softlimit;/* preferred inode limit */
  86. __be64 d_bcount; /* disk blocks owned by the user */
  87. __be64 d_icount; /* inodes owned by the user */
  88. __be32 d_itimer; /* zero if within inode limits if not,
  89. this is when we refuse service */
  90. __be32 d_btimer; /* similar to above; for disk blocks */
  91. __be16 d_iwarns; /* warnings issued wrt num inodes */
  92. __be16 d_bwarns; /* warnings issued wrt disk blocks */
  93. __be32 d_pad0; /* 64 bit align */
  94. __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */
  95. __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */
  96. __be64 d_rtbcount; /* realtime blocks owned */
  97. __be32 d_rtbtimer; /* similar to above; for RT disk blocks */
  98. __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */
  99. __be16 d_pad;
  100. } xfs_disk_dquot_t;
  101. /*
  102. * This is what goes on disk. This is separated from the xfs_disk_dquot because
  103. * carrying the unnecessary padding would be a waste of memory.
  104. */
  105. typedef struct xfs_dqblk {
  106. xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */
  107. char dd_fill[4]; /* filling for posterity */
  108. /*
  109. * These two are only present on filesystems with the CRC bits set.
  110. */
  111. __be32 dd_crc; /* checksum */
  112. __be64 dd_lsn; /* last modification in log */
  113. uuid_t dd_uuid; /* location information */
  114. } xfs_dqblk_t;
  115. #define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc)
  116. /*
  117. * Remote symlink format and access functions.
  118. */
  119. #define XFS_SYMLINK_MAGIC 0x58534c4d /* XSLM */
  120. struct xfs_dsymlink_hdr {
  121. __be32 sl_magic;
  122. __be32 sl_offset;
  123. __be32 sl_bytes;
  124. __be32 sl_crc;
  125. uuid_t sl_uuid;
  126. __be64 sl_owner;
  127. __be64 sl_blkno;
  128. __be64 sl_lsn;
  129. };
  130. /*
  131. * The maximum pathlen is 1024 bytes. Since the minimum file system
  132. * blocksize is 512 bytes, we can get a max of 3 extents back from
  133. * bmapi when crc headers are taken into account.
  134. */
  135. #define XFS_SYMLINK_MAPS 3
  136. #define XFS_SYMLINK_BUF_SPACE(mp, bufsize) \
  137. ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \
  138. sizeof(struct xfs_dsymlink_hdr) : 0))
  139. int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
  140. int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
  141. uint32_t size, struct xfs_buf *bp);
  142. bool xfs_symlink_hdr_ok(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
  143. uint32_t size, struct xfs_buf *bp);
  144. void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
  145. struct xfs_inode *ip, struct xfs_ifork *ifp);
  146. extern const struct xfs_buf_ops xfs_symlink_buf_ops;
  147. #endif /* __XFS_FORMAT_H__ */