Blame view

fs/xfs/xfs_linux.h 7.26 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
7b7187698   Nathan Scott   [XFS] Update lice...
2
3
   * Copyright (c) 2000-2005 Silicon Graphics, Inc.
   * All Rights Reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
   *
7b7187698   Nathan Scott   [XFS] Update lice...
5
6
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
   * published by the Free Software Foundation.
   *
7b7187698   Nathan Scott   [XFS] Update lice...
9
10
11
12
   * This program is distributed in the hope that it would be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
   *
7b7187698   Nathan Scott   [XFS] Update lice...
14
15
16
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write the Free Software Foundation,
   * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
20
21
   */
  #ifndef __XFS_LINUX__
  #define __XFS_LINUX__
  
  #include <linux/types.h>
b1f359f98   Christoph Hellwig   xfs: use uuid_be ...
22
  #include <linux/uuid.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
  
  /*
4f3d71f68   Dave Chinner   xfs: move kernel ...
25
26
   * Kernel specific type declarations for XFS
   */
4f3d71f68   Dave Chinner   xfs: move kernel ...
27

4f3d71f68   Dave Chinner   xfs: move kernel ...
28
29
30
  typedef __s64			xfs_off_t;	/* <file offset> type */
  typedef unsigned long long	xfs_ino_t;	/* <inode> type */
  typedef __s64			xfs_daddr_t;	/* <disk address> type */
4f3d71f68   Dave Chinner   xfs: move kernel ...
31
32
  typedef __u32			xfs_dev_t;
  typedef __u32			xfs_nlink_t;
06f8e2d67   Alex Elder   xfs: don't expect...
33
  #include "xfs_types.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34

06f8e2d67   Alex Elder   xfs: don't expect...
35
36
  #include "kmem.h"
  #include "mrlock.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37

ab4a9b04a   David Chinner   [XFS] remove the ...
38
  #include <linux/semaphore.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
41
42
  #include <linux/mm.h>
  #include <linux/kernel.h>
  #include <linux/blkdev.h>
  #include <linux/slab.h>
bc02e8693   Christoph Hellwig   xfs: add CRC infr...
43
  #include <linux/crc32c.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
  #include <linux/module.h>
a0b0b8a5b   Christoph Hellwig   xfs: kill mutex_t...
45
  #include <linux/mutex.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
  #include <linux/file.h>
  #include <linux/swap.h>
  #include <linux/errno.h>
174cd4b1e   Ingo Molnar   sched/headers: Pr...
49
  #include <linux/sched/signal.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
53
54
55
56
57
  #include <linux/bitops.h>
  #include <linux/major.h>
  #include <linux/pagemap.h>
  #include <linux/vfs.h>
  #include <linux/seq_file.h>
  #include <linux/init.h>
  #include <linux/list.h>
  #include <linux/proc_fs.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
  #include <linux/sort.h>
e8234a687   David Chinner   [XFS] Add support...
59
60
  #include <linux/cpu.h>
  #include <linux/notifier.h>
01e1b69cf   David Chinner   [XFS] using a spi...
61
  #include <linux/delay.h>
af3a2e8a3   Eric Sandeen   [XFS] move linux/...
62
  #include <linux/log2.h>
007c61c68   Eric Sandeen   [XFS] Remove spin.h
63
  #include <linux/spinlock.h>
64275ea4f   David Chinner   [XFS] Include lin...
64
  #include <linux/random.h>
189f4bf22   Barry Naujok   [XFS] XFS: ASCII ...
65
  #include <linux/ctype.h>
6bfb3d065   David Chinner   [XFS] Fix race wh...
66
  #include <linux/writeback.h>
6c77b0ea1   Christoph Hellwig   xfs: remove xfs_c...
67
  #include <linux/capability.h>
0030807c6   Christoph Hellwig   xfs: revert to us...
68
69
  #include <linux/kthread.h>
  #include <linux/freezer.h>
8a072a4d4   Christoph Hellwig   xfs: reduce the n...
70
  #include <linux/list_sort.h>
3d6e03619   Rich Johnston   xfs: Add ratelimi...
71
  #include <linux/ratelimit.h>
6031e73a5   Lucas Stach   xfs: use rhashtab...
72
  #include <linux/rhashtable.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
75
76
  
  #include <asm/page.h>
  #include <asm/div64.h>
  #include <asm/param.h>
7c0f6ba68   Linus Torvalds   Replace <asm/uacc...
77
  #include <linux/uaccess.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
79
  #include <asm/byteorder.h>
  #include <asm/unaligned.h>
b92cc59f6   Dave Chinner   xfs: kill xfs_vno...
80
  #include "xfs_fs.h"
06f8e2d67   Alex Elder   xfs: don't expect...
81
82
83
84
85
  #include "xfs_stats.h"
  #include "xfs_sysctl.h"
  #include "xfs_iops.h"
  #include "xfs_aops.h"
  #include "xfs_super.h"
515821705   Eric Sandeen   xfs: add helper f...
86
  #include "xfs_cksum.h"
06f8e2d67   Alex Elder   xfs: don't expect...
87
88
  #include "xfs_buf.h"
  #include "xfs_message.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89

218106a11   Christoph Hellwig   xfs: use generic ...
90
91
92
93
94
  #ifdef __BIG_ENDIAN
  #define XFS_NATIVE_HOST 1
  #else
  #undef XFS_NATIVE_HOST
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
101
102
103
  #define irix_sgid_inherit	xfs_params.sgid_inherit.val
  #define irix_symlink_mode	xfs_params.symlink_mode.val
  #define xfs_panic_mask		xfs_params.panic_mask.val
  #define xfs_error_level		xfs_params.error_level.val
  #define xfs_syncd_centisecs	xfs_params.syncd_timer.val
  #define xfs_stats_clear		xfs_params.stats_clear.val
  #define xfs_inherit_sync	xfs_params.inherit_sync.val
  #define xfs_inherit_nodump	xfs_params.inherit_nodump.val
  #define xfs_inherit_noatime	xfs_params.inherit_noatim.val
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
105
  #define xfs_inherit_nosymlinks	xfs_params.inherit_nosym.val
  #define xfs_rotorstep		xfs_params.rotorstep.val
d3446eac3   Barry Naujok   [XFS] Add degfram...
106
  #define xfs_inherit_nodefrag	xfs_params.inherit_nodfrg.val
2a82b8be8   David Chinner   [XFS] Concurrent ...
107
  #define xfs_fstrm_centisecs	xfs_params.fstrm_timer.val
579b62faa   Brian Foster   xfs: add backgrou...
108
  #define xfs_eofb_secs		xfs_params.eofb_timer.val
83104d449   Darrick J. Wong   xfs: garbage coll...
109
  #define xfs_cowb_secs		xfs_params.cowb_timer.val
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110

59c1b082f   Nathan Scott   [XFS] Make the pf...
111
  #define current_cpu()		(raw_smp_processor_id())
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
  #define current_pid()		(current->pid)
59c1b082f   Nathan Scott   [XFS] Make the pf...
113
  #define current_test_flags(f)	(current->flags & (f))
59c1b082f   Nathan Scott   [XFS] Make the pf...
114
115
116
117
118
119
  #define current_set_flags_nested(sp, f)		\
  		(*(sp) = current->flags, current->flags |= (f))
  #define current_clear_flags_nested(sp, f)	\
  		(*(sp) = current->flags, current->flags &= ~(f))
  #define current_restore_flags_nested(sp, f)	\
  		(current->flags = ((current->flags & ~(f)) | (*(sp) & (f))))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120

007c61c68   Eric Sandeen   [XFS] Remove spin.h
121
  #define spinlock_destroy(lock)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122
  #define NBBY		8		/* number of bits per byte */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123
124
125
126
127
  
  /*
   * Size of block device i/o is parameterized here.
   * Currently the system supports page-sized i/o.
   */
09cbfeaf1   Kirill A. Shutemov   mm, fs: get rid o...
128
  #define	BLKDEV_IOSHIFT		PAGE_SHIFT
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
131
  #define	BLKDEV_IOSIZE		(1<<BLKDEV_IOSHIFT)
  /* number of BB's per block device block */
  #define	BLKDEV_BB		BTOBB(BLKDEV_IOSIZE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
  #define ENOATTR		ENODATA		/* Attribute not found */
da2f4d679   Nathan Scott   [XFS] Map EFSCORR...
133
134
  #define EWRONGFS	EINVAL		/* Mount with wrong filesystem type */
  #define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
ca23f8fdd   Eric Sandeen   xfs: add xfs_veri...
135
  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
137
138
  
  #define SYNCHRONIZE()	barrier()
  #define __return_address __builtin_return_address(0)
6743099ce   Arkadiusz Mi?kiewicz   xfs: Extend proje...
139
  #define XFS_PROJID_DEFAULT	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
  
  #define MIN(a,b)	(min(a,b))
  #define MAX(a,b)	(max(a,b))
  #define howmany(x, y)	(((x)+((y)-1))/(y))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144

e076b0f3a   Dave Chinner   xfs: kill time.h
145
146
147
148
  static inline void delay(long ticks)
  {
  	schedule_timeout_uninterruptible(ticks);
  }
a31b1d3d8   Brian Foster   xfs: add xfs_moun...
149
150
151
152
153
154
155
156
157
158
  /*
   * XFS wrapper structure for sysfs support. It depends on external data
   * structures and is embedded in various internal data structures to implement
   * the XFS sysfs object heirarchy. Define it here for broad access throughout
   * the codebase.
   */
  struct xfs_kobj {
  	struct kobject		kobject;
  	struct completion	complete;
  };
80529c45a   Bill O'Donnell   xfs: pass xfsstat...
159
160
161
162
163
164
  struct xstats {
  	struct xfsstats __percpu	*xs_stats;
  	struct xfs_kobj			xs_kobj;
  };
  
  extern struct xstats xfsstats;
c5eeb7ec3   Dwight Engen   xfs: create wrapp...
165
166
167
168
169
170
  /* Kernel uid/gid conversion. These are used to convert to/from the on disk
   * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally.
   * The conversion here is type only, the value will remain the same since we
   * are converting to the init_user_ns. The uid is later mapped to a particular
   * user namespace value when crossing the kernel/user boundary.
   */
c8ce540db   Darrick J. Wong   xfs: remove doubl...
171
  static inline uint32_t xfs_kuid_to_uid(kuid_t uid)
c5eeb7ec3   Dwight Engen   xfs: create wrapp...
172
173
174
  {
  	return from_kuid(&init_user_ns, uid);
  }
c8ce540db   Darrick J. Wong   xfs: remove doubl...
175
  static inline kuid_t xfs_uid_to_kuid(uint32_t uid)
c5eeb7ec3   Dwight Engen   xfs: create wrapp...
176
177
178
  {
  	return make_kuid(&init_user_ns, uid);
  }
c8ce540db   Darrick J. Wong   xfs: remove doubl...
179
  static inline uint32_t xfs_kgid_to_gid(kgid_t gid)
c5eeb7ec3   Dwight Engen   xfs: create wrapp...
180
181
182
  {
  	return from_kgid(&init_user_ns, gid);
  }
c8ce540db   Darrick J. Wong   xfs: remove doubl...
183
  static inline kgid_t xfs_gid_to_kgid(uint32_t gid)
c5eeb7ec3   Dwight Engen   xfs: create wrapp...
184
185
186
  {
  	return make_kgid(&init_user_ns, gid);
  }
cde410a99   Nathan Scott   [XFS] Sort out so...
187
188
189
  /*
   * Various platform dependent calls that don't fit anywhere else
   */
380b5dc0e   Nathan Scott   [XFS] Fix up an i...
190
  #define xfs_sort(a,n,s,fn)	sort(a,n,s,fn,NULL)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
191
  #define xfs_stack_trace()	dump_stack()
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
192

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
  /* Side effect free 64 bit mod operation */
  static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
  {
  	switch (n) {
  		case 4:
  			return *(__u32 *)a % b;
  		case 8:
  			{
  			__u64	c = *(__u64 *)a;
  			return do_div(c, b);
  			}
  	}
  
  	/* NOTREACHED */
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
209

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
  #define do_mod(a, b)	xfs_do_mod(&(a), (b), sizeof(a))
c8ce540db   Darrick J. Wong   xfs: remove doubl...
211
  static inline uint64_t roundup_64(uint64_t x, uint32_t y)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
212
213
214
  {
  	x += y - 1;
  	do_div(x, y);
d99831ff3   Eric Sandeen   xfs: return is no...
215
  	return x * y;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216
  }
c8ce540db   Darrick J. Wong   xfs: remove doubl...
217
  static inline uint64_t howmany_64(uint64_t x, uint32_t y)
68c327151   Nathan Scott   [XFS] Fix a porti...
218
219
220
221
222
  {
  	x += y - 1;
  	do_div(x, y);
  	return x;
  }
9130090b5   Dave Chinner   xfs: kill support...
223
  #define ASSERT_ALWAYS(expr)	\
bf46ecc3d   Amir Goldstein   xfs: make the ASS...
224
  	(likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
9130090b5   Dave Chinner   xfs: kill support...
225

742ae1e35   Dave Chinner   xfs: introduce CO...
226
227
  #ifdef DEBUG
  #define ASSERT(expr)	\
bf46ecc3d   Amir Goldstein   xfs: make the ASS...
228
  	(likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
9130090b5   Dave Chinner   xfs: kill support...
229
230
  
  #ifndef STATIC
742ae1e35   Dave Chinner   xfs: introduce CO...
231
  # define STATIC noinline
9130090b5   Dave Chinner   xfs: kill support...
232
  #endif
742ae1e35   Dave Chinner   xfs: introduce CO...
233
234
235
  #else	/* !DEBUG */
  
  #ifdef XFS_WARN
9130090b5   Dave Chinner   xfs: kill support...
236
237
  
  #define ASSERT(expr)	\
bf46ecc3d   Amir Goldstein   xfs: make the ASS...
238
  	(likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__))
9130090b5   Dave Chinner   xfs: kill support...
239
240
  
  #ifndef STATIC
742ae1e35   Dave Chinner   xfs: introduce CO...
241
242
243
244
245
246
247
248
249
  # define STATIC static noinline
  #endif
  
  #else	/* !DEBUG && !XFS_WARN */
  
  #define ASSERT(expr)	((void)0)
  
  #ifndef STATIC
  # define STATIC static noinline
9130090b5   Dave Chinner   xfs: kill support...
250
  #endif
742ae1e35   Dave Chinner   xfs: introduce CO...
251
  #endif /* XFS_WARN */
9130090b5   Dave Chinner   xfs: kill support...
252
  #endif /* DEBUG */
6d3ebaae7   Christoph Hellwig   xfs: merge xfs_di...
253
  #ifdef CONFIG_XFS_RT
b31ff3cdf   Richard Wareing   xfs: XFS_IS_REALT...
254
255
256
257
258
259
260
261
  
  /*
   * make sure we ignore the inode flag if the filesystem doesn't have a
   * configured realtime device.
   */
  #define XFS_IS_REALTIME_INODE(ip)			\
  	(((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) &&	\
  	 (ip)->i_mount->m_rtdev_targp)
6d3ebaae7   Christoph Hellwig   xfs: merge xfs_di...
262
263
264
  #else
  #define XFS_IS_REALTIME_INODE(ip) (0)
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
265
  #endif /* __XFS_LINUX__ */