Linux 3.12.28
[linux/fpc-iii.git] / fs / xfs / xfs_format.h
blob35c08ff54ca079dcf6c718d6b2d6b75bf24f1721
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
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.
30 struct xfs_mount;
31 struct xfs_trans;
32 struct xfs_inode;
33 struct xfs_buf;
34 struct xfs_ifork;
37 * RealTime Device format definitions
40 /* Min and max rt extent sizes, specified in bytes */
41 #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */
42 #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64kB */
43 #define XFS_MIN_RTEXTSIZE (4 * 1024) /* 4kB */
45 #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
46 #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
47 #define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
48 #define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
51 * RT Summary and bit manipulation macros.
53 #define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
54 #define XFS_SUMOFFSTOBLOCK(mp,s) \
55 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
56 #define XFS_SUMPTR(mp,bp,so) \
57 ((xfs_suminfo_t *)((bp)->b_addr + \
58 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
60 #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
61 #define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
62 #define XFS_BITTOWORD(mp,bi) \
63 ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
65 #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
66 #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
68 #define XFS_RTLOBIT(w) xfs_lowbit32(w)
69 #define XFS_RTHIBIT(w) xfs_highbit32(w)
71 #if XFS_BIG_BLKNOS
72 #define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
73 #else
74 #define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
75 #endif
78 * Dquot and dquot block format definitions
80 #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */
81 #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */
84 * This is the main portion of the on-disk representation of quota
85 * information for a user. This is the q_core of the xfs_dquot_t that
86 * is kept in kernel memory. We pad this with some more expansion room
87 * to construct the on disk structure.
89 typedef struct xfs_disk_dquot {
90 __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */
91 __u8 d_version; /* dquot version */
92 __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */
93 __be32 d_id; /* user,project,group id */
94 __be64 d_blk_hardlimit;/* absolute limit on disk blks */
95 __be64 d_blk_softlimit;/* preferred limit on disk blks */
96 __be64 d_ino_hardlimit;/* maximum # allocated inodes */
97 __be64 d_ino_softlimit;/* preferred inode limit */
98 __be64 d_bcount; /* disk blocks owned by the user */
99 __be64 d_icount; /* inodes owned by the user */
100 __be32 d_itimer; /* zero if within inode limits if not,
101 this is when we refuse service */
102 __be32 d_btimer; /* similar to above; for disk blocks */
103 __be16 d_iwarns; /* warnings issued wrt num inodes */
104 __be16 d_bwarns; /* warnings issued wrt disk blocks */
105 __be32 d_pad0; /* 64 bit align */
106 __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */
107 __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */
108 __be64 d_rtbcount; /* realtime blocks owned */
109 __be32 d_rtbtimer; /* similar to above; for RT disk blocks */
110 __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */
111 __be16 d_pad;
112 } xfs_disk_dquot_t;
115 * This is what goes on disk. This is separated from the xfs_disk_dquot because
116 * carrying the unnecessary padding would be a waste of memory.
118 typedef struct xfs_dqblk {
119 xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */
120 char dd_fill[4]; /* filling for posterity */
123 * These two are only present on filesystems with the CRC bits set.
125 __be32 dd_crc; /* checksum */
126 __be64 dd_lsn; /* last modification in log */
127 uuid_t dd_uuid; /* location information */
128 } xfs_dqblk_t;
130 #define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc)
133 * Remote symlink format and access functions.
135 #define XFS_SYMLINK_MAGIC 0x58534c4d /* XSLM */
137 struct xfs_dsymlink_hdr {
138 __be32 sl_magic;
139 __be32 sl_offset;
140 __be32 sl_bytes;
141 __be32 sl_crc;
142 uuid_t sl_uuid;
143 __be64 sl_owner;
144 __be64 sl_blkno;
145 __be64 sl_lsn;
149 * The maximum pathlen is 1024 bytes. Since the minimum file system
150 * blocksize is 512 bytes, we can get a max of 3 extents back from
151 * bmapi when crc headers are taken into account.
153 #define XFS_SYMLINK_MAPS 3
155 #define XFS_SYMLINK_BUF_SPACE(mp, bufsize) \
156 ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \
157 sizeof(struct xfs_dsymlink_hdr) : 0))
159 int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
160 int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
161 uint32_t size, struct xfs_buf *bp);
162 bool xfs_symlink_hdr_ok(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
163 uint32_t size, struct xfs_buf *bp);
164 void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
165 struct xfs_inode *ip, struct xfs_ifork *ifp);
167 extern const struct xfs_buf_ops xfs_symlink_buf_ops;
169 #endif /* __XFS_FORMAT_H__ */