2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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.
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.
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
18 #ifndef __XFS_FORMAT_H__
19 #define __XFS_FORMAT_H__
22 * XFS On Disk Format Definitions
24 * This header file defines all the on-disk format definitions for
25 * general XFS objects. Directory and attribute related objects are defined in
26 * xfs_da_format.h, which log and log item formats are defined in
27 * xfs_log_format.h. Everything else goes here.
31 * RealTime Device format definitions
34 /* Min and max rt extent sizes, specified in bytes */
35 #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */
36 #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64kB */
37 #define XFS_MIN_RTEXTSIZE (4 * 1024) /* 4kB */
39 #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
40 #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
41 #define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
42 #define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
45 * RT Summary and bit manipulation macros.
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))))
54 #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
55 #define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
56 #define XFS_BITTOWORD(mp,bi) \
57 ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
59 #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
60 #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
62 #define XFS_RTLOBIT(w) xfs_lowbit32(w)
63 #define XFS_RTHIBIT(w) xfs_highbit32(w)
66 #define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
68 #define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
72 * Dquot and dquot block format definitions
74 #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */
75 #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */
78 * This is the main portion of the on-disk representation of quota
79 * information for a user. This is the q_core of the xfs_dquot_t that
80 * is kept in kernel memory. We pad this with some more expansion room
81 * to construct the on disk structure.
83 typedef struct xfs_disk_dquot
{
84 __be16 d_magic
; /* dquot magic = XFS_DQUOT_MAGIC */
85 __u8 d_version
; /* dquot version */
86 __u8 d_flags
; /* XFS_DQ_USER/PROJ/GROUP */
87 __be32 d_id
; /* user,project,group id */
88 __be64 d_blk_hardlimit
;/* absolute limit on disk blks */
89 __be64 d_blk_softlimit
;/* preferred limit on disk blks */
90 __be64 d_ino_hardlimit
;/* maximum # allocated inodes */
91 __be64 d_ino_softlimit
;/* preferred inode limit */
92 __be64 d_bcount
; /* disk blocks owned by the user */
93 __be64 d_icount
; /* inodes owned by the user */
94 __be32 d_itimer
; /* zero if within inode limits if not,
95 this is when we refuse service */
96 __be32 d_btimer
; /* similar to above; for disk blocks */
97 __be16 d_iwarns
; /* warnings issued wrt num inodes */
98 __be16 d_bwarns
; /* warnings issued wrt disk blocks */
99 __be32 d_pad0
; /* 64 bit align */
100 __be64 d_rtb_hardlimit
;/* absolute limit on realtime blks */
101 __be64 d_rtb_softlimit
;/* preferred limit on RT disk blks */
102 __be64 d_rtbcount
; /* realtime blocks owned */
103 __be32 d_rtbtimer
; /* similar to above; for RT disk blocks */
104 __be16 d_rtbwarns
; /* warnings issued wrt RT disk blocks */
109 * This is what goes on disk. This is separated from the xfs_disk_dquot because
110 * carrying the unnecessary padding would be a waste of memory.
112 typedef struct xfs_dqblk
{
113 xfs_disk_dquot_t dd_diskdq
; /* portion that lives incore as well */
114 char dd_fill
[4]; /* filling for posterity */
117 * These two are only present on filesystems with the CRC bits set.
119 __be32 dd_crc
; /* checksum */
120 __be64 dd_lsn
; /* last modification in log */
121 uuid_t dd_uuid
; /* location information */
124 #define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc)
127 #endif /* __XFS_FORMAT_H__ */