xfs: remove xfs_globals.h
[deliverable/linux.git] / fs / xfs / linux-2.6 / xfs_linux.h
CommitLineData
1da177e4 1/*
7b718769
NS
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
7b718769
NS
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
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
7b718769
NS
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.
1da177e4 13 *
7b718769
NS
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
1da177e4
LT
17 */
18#ifndef __XFS_LINUX__
19#define __XFS_LINUX__
20
21#include <linux/types.h>
1da177e4
LT
22
23/*
1da177e4 24 * XFS_BIG_BLKNOS needs block layer disk addresses to be 64 bits.
6c31b93a 25 * XFS_BIG_INUMS requires XFS_BIG_BLKNOS to be set.
1da177e4 26 */
90c699a9 27#if defined(CONFIG_LBDAF) || (BITS_PER_LONG == 64)
1da177e4 28# define XFS_BIG_BLKNOS 1
6c31b93a 29# define XFS_BIG_INUMS 1
1da177e4
LT
30#else
31# define XFS_BIG_BLKNOS 0
32# define XFS_BIG_INUMS 0
33#endif
34
35#include <xfs_types.h>
36#include <xfs_arch.h>
37
38#include <kmem.h>
39#include <mrlock.h>
1da177e4 40#include <sv.h>
1da177e4
LT
41#include <time.h>
42
1da177e4 43#include <support/debug.h>
1da177e4
LT
44#include <support/uuid.h>
45
ab4a9b04 46#include <linux/semaphore.h>
1da177e4
LT
47#include <linux/mm.h>
48#include <linux/kernel.h>
49#include <linux/blkdev.h>
50#include <linux/slab.h>
51#include <linux/module.h>
a0b0b8a5 52#include <linux/mutex.h>
1da177e4
LT
53#include <linux/file.h>
54#include <linux/swap.h>
55#include <linux/errno.h>
56#include <linux/sched.h>
57#include <linux/bitops.h>
58#include <linux/major.h>
59#include <linux/pagemap.h>
60#include <linux/vfs.h>
61#include <linux/seq_file.h>
62#include <linux/init.h>
63#include <linux/list.h>
64#include <linux/proc_fs.h>
1da177e4 65#include <linux/sort.h>
e8234a68
DC
66#include <linux/cpu.h>
67#include <linux/notifier.h>
01e1b69c 68#include <linux/delay.h>
af3a2e8a 69#include <linux/log2.h>
007c61c6 70#include <linux/spinlock.h>
64275ea4 71#include <linux/random.h>
189f4bf2 72#include <linux/ctype.h>
6bfb3d06 73#include <linux/writeback.h>
1da177e4
LT
74
75#include <asm/page.h>
76#include <asm/div64.h>
77#include <asm/param.h>
78#include <asm/uaccess.h>
79#include <asm/byteorder.h>
80#include <asm/unaligned.h>
81
1da177e4
LT
82#include <xfs_cred.h>
83#include <xfs_vnode.h>
84#include <xfs_stats.h>
85#include <xfs_sysctl.h>
86#include <xfs_iops.h>
0829c360 87#include <xfs_aops.h>
1da177e4 88#include <xfs_super.h>
1da177e4
LT
89#include <xfs_buf.h>
90
91/*
92 * Feature macros (disable/enable)
93 */
d2c32edf 94#ifdef CONFIG_SMP
8d280b98
DC
95#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
96#else
97#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
98#endif
1da177e4 99
1da177e4
LT
100#define irix_sgid_inherit xfs_params.sgid_inherit.val
101#define irix_symlink_mode xfs_params.symlink_mode.val
102#define xfs_panic_mask xfs_params.panic_mask.val
103#define xfs_error_level xfs_params.error_level.val
104#define xfs_syncd_centisecs xfs_params.syncd_timer.val
105#define xfs_stats_clear xfs_params.stats_clear.val
106#define xfs_inherit_sync xfs_params.inherit_sync.val
107#define xfs_inherit_nodump xfs_params.inherit_nodump.val
108#define xfs_inherit_noatime xfs_params.inherit_noatim.val
109#define xfs_buf_timer_centisecs xfs_params.xfs_buf_timer.val
110#define xfs_buf_age_centisecs xfs_params.xfs_buf_age.val
111#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
112#define xfs_rotorstep xfs_params.rotorstep.val
d3446eac 113#define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val
2a82b8be 114#define xfs_fstrm_centisecs xfs_params.fstrm_timer.val
1da177e4 115
59c1b082 116#define current_cpu() (raw_smp_processor_id())
1da177e4 117#define current_pid() (current->pid)
59c1b082 118#define current_test_flags(f) (current->flags & (f))
59c1b082
NS
119#define current_set_flags_nested(sp, f) \
120 (*(sp) = current->flags, current->flags |= (f))
121#define current_clear_flags_nested(sp, f) \
122 (*(sp) = current->flags, current->flags &= ~(f))
123#define current_restore_flags_nested(sp, f) \
124 (current->flags = ((current->flags & ~(f)) | (*(sp) & (f))))
1da177e4 125
007c61c6
ES
126#define spinlock_destroy(lock)
127
1da177e4 128#define NBBY 8 /* number of bits per byte */
1da177e4
LT
129
130/*
131 * Size of block device i/o is parameterized here.
132 * Currently the system supports page-sized i/o.
133 */
e6a4b37f 134#define BLKDEV_IOSHIFT PAGE_CACHE_SHIFT
1da177e4
LT
135#define BLKDEV_IOSIZE (1<<BLKDEV_IOSHIFT)
136/* number of BB's per block device block */
137#define BLKDEV_BB BTOBB(BLKDEV_IOSIZE)
138
1da177e4 139#define ENOATTR ENODATA /* Attribute not found */
da2f4d67
NS
140#define EWRONGFS EINVAL /* Mount with wrong filesystem type */
141#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
1da177e4
LT
142
143#define SYNCHRONIZE() barrier()
144#define __return_address __builtin_return_address(0)
145
6b3f6b5b 146#define dfltprid 0
1da177e4
LT
147#define MAXPATHLEN 1024
148
149#define MIN(a,b) (min(a,b))
150#define MAX(a,b) (max(a,b))
151#define howmany(x, y) (((x)+((y)-1))/(y))
1da177e4 152
cde410a9
NS
153/*
154 * Various platform dependent calls that don't fit anywhere else
155 */
380b5dc0 156#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
1da177e4 157#define xfs_stack_trace() dump_stack()
1da177e4
LT
158
159
160/* Move the kernel do_div definition off to one side */
161
162#if defined __i386__
163/* For ia32 we need to pull some tricks to get past various versions
164 * of the compiler which do not like us using do_div in the middle
165 * of large functions.
166 */
167static inline __u32 xfs_do_div(void *a, __u32 b, int n)
168{
169 __u32 mod;
170
171 switch (n) {
172 case 4:
173 mod = *(__u32 *)a % b;
174 *(__u32 *)a = *(__u32 *)a / b;
175 return mod;
176 case 8:
177 {
178 unsigned long __upper, __low, __high, __mod;
179 __u64 c = *(__u64 *)a;
180 __upper = __high = c >> 32;
181 __low = c;
182 if (__high) {
183 __upper = __high % (b);
184 __high = __high / (b);
185 }
186 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
187 asm("":"=A" (c):"a" (__low),"d" (__high));
188 *(__u64 *)a = c;
189 return __mod;
190 }
191 }
192
193 /* NOTREACHED */
194 return 0;
195}
196
197/* Side effect free 64 bit mod operation */
198static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
199{
200 switch (n) {
201 case 4:
202 return *(__u32 *)a % b;
203 case 8:
204 {
205 unsigned long __upper, __low, __high, __mod;
206 __u64 c = *(__u64 *)a;
207 __upper = __high = c >> 32;
208 __low = c;
209 if (__high) {
210 __upper = __high % (b);
211 __high = __high / (b);
212 }
213 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
214 asm("":"=A" (c):"a" (__low),"d" (__high));
215 return __mod;
216 }
217 }
218
219 /* NOTREACHED */
220 return 0;
221}
222#else
223static inline __u32 xfs_do_div(void *a, __u32 b, int n)
224{
225 __u32 mod;
226
227 switch (n) {
228 case 4:
229 mod = *(__u32 *)a % b;
230 *(__u32 *)a = *(__u32 *)a / b;
231 return mod;
232 case 8:
233 mod = do_div(*(__u64 *)a, b);
234 return mod;
235 }
236
237 /* NOTREACHED */
238 return 0;
239}
240
241/* Side effect free 64 bit mod operation */
242static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
243{
244 switch (n) {
245 case 4:
246 return *(__u32 *)a % b;
247 case 8:
248 {
249 __u64 c = *(__u64 *)a;
250 return do_div(c, b);
251 }
252 }
253
254 /* NOTREACHED */
255 return 0;
256}
257#endif
258
259#undef do_div
260#define do_div(a, b) xfs_do_div(&(a), (b), sizeof(a))
261#define do_mod(a, b) xfs_do_mod(&(a), (b), sizeof(a))
262
263static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
264{
265 x += y - 1;
266 do_div(x, y);
267 return(x * y);
268}
269
68c32715
NS
270static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y)
271{
272 x += y - 1;
273 do_div(x, y);
274 return x;
275}
276
ae23a5e8
ES
277/* ARM old ABI has some weird alignment/padding */
278#if defined(__arm__) && !defined(__ARM_EABI__)
279#define __arch_pack __attribute__((packed))
280#else
281#define __arch_pack
282#endif
283
1da177e4 284#endif /* __XFS_LINUX__ */
This page took 0.770695 seconds and 5 git commands to generate.