]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_types.h
Undoes mod: xfs-cmds:slinx:120772a
[thirdparty/xfsprogs-dev.git] / include / xfs_types.h
1 /*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32 #ifndef __XFS_TYPES_H__
33 #define __XFS_TYPES_H__
34
35 /*
36 * Some types are conditional based on the selected configuration.
37 * Set XFS_BIG_FILES=1 or 0 and XFS_BIG_FILESYSTEMS=1 or 0 depending
38 * on the desired configuration.
39 * XFS_BIG_FILES needs pgno_t to be 64 bits (64-bit kernels).
40 * XFS_BIG_FILESYSTEMS needs daddr_t to be 64 bits (N32 and 64-bit kernels).
41 *
42 * Expect these to be set from klocaldefs, or from the machine-type
43 * defs files for the normal case.
44 */
45
46 #define XFS_BIG_FILES 1
47 #define XFS_BIG_FILESYSTEMS 1
48
49 typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */
50 typedef __uint32_t xfs_extlen_t; /* extent length in blocks */
51 typedef __uint32_t xfs_agnumber_t; /* allocation group number */
52 typedef __int32_t xfs_extnum_t; /* # of extents in a file */
53 typedef __int16_t xfs_aextnum_t; /* # extents in an attribute fork */
54 typedef __int64_t xfs_fsize_t; /* bytes in a file */
55 typedef __uint64_t xfs_ufsize_t; /* unsigned bytes in a file */
56
57 typedef __int32_t xfs_suminfo_t; /* type of bitmap summary info */
58 typedef __int32_t xfs_rtword_t; /* word type for bitmap manipulations */
59
60 typedef __int64_t xfs_lsn_t; /* log sequence number */
61 typedef __int32_t xfs_tid_t; /* transaction identifier */
62
63 typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */
64 typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */
65
66 typedef __uint16_t xfs_prid_t; /* prid_t truncated to 16bits in XFS */
67
68 /*
69 * These types are 64 bits on disk but are either 32 or 64 bits in memory.
70 * Disk based types:
71 */
72 typedef __uint64_t xfs_dfsbno_t; /* blockno in filesystem (agno|agbno) */
73 typedef __uint64_t xfs_drfsbno_t; /* blockno in filesystem (raw) */
74 typedef __uint64_t xfs_drtbno_t; /* extent (block) in realtime area */
75 typedef __uint64_t xfs_dfiloff_t; /* block number in a file */
76 typedef __uint64_t xfs_dfilblks_t; /* number of blocks in a file */
77
78 /*
79 * Memory based types are conditional.
80 */
81 #if XFS_BIG_FILESYSTEMS
82 typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
83 typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
84 typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */
85 typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */
86 #else
87 typedef __uint32_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
88 typedef __uint32_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
89 typedef __uint32_t xfs_rtblock_t; /* extent (block) in realtime area */
90 typedef __int32_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */
91 #endif
92 #if XFS_BIG_FILES
93 typedef __uint64_t xfs_fileoff_t; /* block number in a file */
94 typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */
95 typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */
96 #else
97 typedef __uint32_t xfs_fileoff_t; /* block number in a file */
98 typedef __int32_t xfs_sfiloff_t; /* signed block number in a file */
99 typedef __uint32_t xfs_filblks_t; /* number of blocks in a file */
100 #endif
101
102 typedef __uint8_t xfs_arch_t; /* architecutre of an xfs fs */
103
104 /*
105 * Null values for the types.
106 */
107 #define NULLDFSBNO ((xfs_dfsbno_t)-1)
108 #define NULLDRFSBNO ((xfs_drfsbno_t)-1)
109 #define NULLDRTBNO ((xfs_drtbno_t)-1)
110 #define NULLDFILOFF ((xfs_dfiloff_t)-1)
111
112 #define NULLFSBLOCK ((xfs_fsblock_t)-1)
113 #define NULLRFSBLOCK ((xfs_rfsblock_t)-1)
114 #define NULLRTBLOCK ((xfs_rtblock_t)-1)
115 #define NULLFILEOFF ((xfs_fileoff_t)-1)
116
117 #define NULLAGBLOCK ((xfs_agblock_t)-1)
118 #define NULLAGNUMBER ((xfs_agnumber_t)-1)
119 #define NULLEXTNUM ((xfs_extnum_t)-1)
120
121 #define NULLCOMMITLSN ((xfs_lsn_t)-1)
122
123 /*
124 * Max values for extlen, extnum, aextnum.
125 */
126 #define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */
127 #define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */
128 #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
129
130 /*
131 * MAXNAMELEN is the length (including the terminating null) of
132 * the longest permissible file (component) name.
133 */
134 #define MAXNAMELEN 256
135
136 typedef enum {
137 XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
138 } xfs_lookup_t;
139
140 typedef enum {
141 XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi,
142 XFS_BTNUM_MAX
143 } xfs_btnum_t;
144
145
146 #if defined(CONFIG_PROC_FS) && defined(__KERNEL__)
147 /*
148 * XFS global statistics
149 */
150 struct xfsstats {
151 # define XFSSTAT_END_EXTENT_ALLOC 4
152 __uint32_t xs_allocx;
153 __uint32_t xs_allocb;
154 __uint32_t xs_freex;
155 __uint32_t xs_freeb;
156 # define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4)
157 __uint32_t xs_abt_lookup;
158 __uint32_t xs_abt_compare;
159 __uint32_t xs_abt_insrec;
160 __uint32_t xs_abt_delrec;
161 # define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7)
162 __uint32_t xs_blk_mapr;
163 __uint32_t xs_blk_mapw;
164 __uint32_t xs_blk_unmap;
165 __uint32_t xs_add_exlist;
166 __uint32_t xs_del_exlist;
167 __uint32_t xs_look_exlist;
168 __uint32_t xs_cmp_exlist;
169 # define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4)
170 __uint32_t xs_bmbt_lookup;
171 __uint32_t xs_bmbt_compare;
172 __uint32_t xs_bmbt_insrec;
173 __uint32_t xs_bmbt_delrec;
174 # define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4)
175 __uint32_t xs_dir_lookup;
176 __uint32_t xs_dir_create;
177 __uint32_t xs_dir_remove;
178 __uint32_t xs_dir_getdents;
179 # define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3)
180 __uint32_t xs_trans_sync;
181 __uint32_t xs_trans_async;
182 __uint32_t xs_trans_empty;
183 # define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7)
184 __uint32_t xs_ig_attempts;
185 __uint32_t xs_ig_found;
186 __uint32_t xs_ig_frecycle;
187 __uint32_t xs_ig_missed;
188 __uint32_t xs_ig_dup;
189 __uint32_t xs_ig_reclaims;
190 __uint32_t xs_ig_attrchg;
191 # define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5)
192 __uint32_t xs_log_writes;
193 __uint32_t xs_log_blocks;
194 __uint32_t xs_log_noiclogs;
195 __uint32_t xs_log_force;
196 __uint32_t xs_log_force_sleep;
197 # define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10)
198 __uint32_t xs_try_logspace;
199 __uint32_t xs_sleep_logspace;
200 __uint32_t xs_push_ail;
201 __uint32_t xs_push_ail_success;
202 __uint32_t xs_push_ail_pushbuf;
203 __uint32_t xs_push_ail_pinned;
204 __uint32_t xs_push_ail_locked;
205 __uint32_t xs_push_ail_flushing;
206 __uint32_t xs_push_ail_restarts;
207 __uint32_t xs_push_ail_flush;
208 # define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2)
209 __uint32_t xs_xstrat_quick;
210 __uint32_t xs_xstrat_split;
211 # define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2)
212 __uint32_t xs_write_calls;
213 __uint32_t xs_read_calls;
214 # define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4)
215 __uint32_t xs_attr_get;
216 __uint32_t xs_attr_set;
217 __uint32_t xs_attr_remove;
218 __uint32_t xs_attr_list;
219 # define XFSSTAT_END_QUOTA_OPS (XFSSTAT_END_ATTRIBUTE_OPS+8)
220 __uint32_t xs_qm_dqreclaims;
221 __uint32_t xs_qm_dqreclaim_misses;
222 __uint32_t xs_qm_dquot_dups;
223 __uint32_t xs_qm_dqcachemisses;
224 __uint32_t xs_qm_dqcachehits;
225 __uint32_t xs_qm_dqwants;
226 __uint32_t xs_qm_dqshake_reclaims;
227 __uint32_t xs_qm_dqinact_reclaims;
228 # define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_QUOTA_OPS+3)
229 __uint32_t xs_iflush_count;
230 __uint32_t xs_icluster_flushcnt;
231 __uint32_t xs_icluster_flushinode;
232 # define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8)
233 __uint32_t vn_active; /* # vnodes not on free lists */
234 __uint32_t vn_alloc; /* # times vn_alloc called */
235 __uint32_t vn_get; /* # times vn_get called */
236 __uint32_t vn_hold; /* # times vn_hold called */
237 __uint32_t vn_rele; /* # times vn_rele called */
238 __uint32_t vn_reclaim; /* # times vn_reclaim called */
239 __uint32_t vn_remove; /* # times vn_remove called */
240 __uint32_t vn_free; /* # times vn_free called */
241 /* Extra precision counters */
242 __uint64_t xs_xstrat_bytes;
243 __uint64_t xs_write_bytes;
244 __uint64_t xs_read_bytes;
245 };
246
247 extern struct xfsstats xfsstats;
248
249 # define XFS_STATS_INC(count) ( (count)++ )
250 # define XFS_STATS_DEC(count) ( (count)-- )
251 # define XFS_STATS_ADD(count, inc) ( (count) += (inc) )
252 #else /* !CONFIG_PROC_FS */
253 # define XFS_STATS_INC(count)
254 # define XFS_STATS_DEC(count)
255 # define XFS_STATS_ADD(count, inc)
256 #endif /* !CONFIG_PROC_FS */
257
258
259
260 /* juggle IRIX device numbers - still used in ondisk structures */
261
262 #ifndef __KERNEL__
263 #define MKDEV(major, minor) makedev(major, minor)
264 #endif
265
266 #define IRIX_DEV_BITSMAJOR 14
267 #define IRIX_DEV_BITSMINOR 18
268 #define IRIX_DEV_MAXMAJ 0x1ff
269 #define IRIX_DEV_MAXMIN 0x3ffff
270 #define IRIX_DEV_MAJOR(dev) ((int)(((unsigned)(dev)>>IRIX_DEV_BITSMINOR) \
271 & IRIX_DEV_MAXMAJ))
272 #define IRIX_DEV_MINOR(dev) ((int)((dev)&IRIX_DEV_MAXMIN))
273 #define IRIX_MKDEV(major,minor) ((xfs_dev_t)(((major)<<IRIX_DEV_BITSMINOR) \
274 | (minor&IRIX_DEV_MAXMIN)))
275
276 #define IRIX_DEV_TO_KDEVT(dev) MKDEV(IRIX_DEV_MAJOR(dev),IRIX_DEV_MINOR(dev))
277
278 #ifdef __KERNEL__
279 /* __psint_t is the same size as a pointer */
280 #if (BITS_PER_LONG == 32)
281 typedef __int32_t __psint_t;
282 typedef __uint32_t __psunsigned_t;
283 #elif (BITS_PER_LONG == 64)
284 typedef __int64_t __psint_t;
285 typedef __uint64_t __psunsigned_t;
286 #else
287 #error BITS_PER_LONG must be 32 or 64
288 #endif
289
290
291 /*
292 * struct for passing owner/requestor id
293 */
294 typedef struct flid {
295 #ifdef CELL_CAPABLE
296 pid_t fl_pid;
297 sysid_t fl_sysid;
298 #endif
299 } flid_t;
300
301 #endif /* __KERNEL__ */
302
303 #endif /* !__XFS_TYPES_H */