]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2bd0ea18 | 2 | /* |
da23017d NS |
3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
2bd0ea18 NS |
5 | */ |
6 | ||
7 | /* | |
8 | * This header is effectively a "namespace multiplexor" for the | |
9 | * user level XFS code. It provides all of the necessary stuff | |
10 | * such that we can build some parts of the XFS kernel code in | |
11 | * user space in a controlled fashion, and translates the names | |
12 | * used in the kernel into the names which libxfs is going to | |
13 | * make available to user tools. | |
14 | * | |
15 | * It should only ever be #include'd by XFS "kernel" code being | |
16 | * compiled in user space. | |
dfc130f3 | 17 | * |
2bd0ea18 NS |
18 | * Our goals here are to... |
19 | * o "share" large amounts of complex code between user and | |
20 | * kernel space; | |
21 | * o shield the user tools from changes in the bleeding | |
22 | * edge kernel code, merging source changes when | |
23 | * convenient and not immediately (no symlinks); | |
24 | * o i.e. be able to merge changes to the kernel source back | |
25 | * into the affected user tools in a controlled fashion; | |
26 | * o provide a _minimalist_ life-support system for kernel | |
27 | * code in user land, not the "everything + the kitchen | |
28 | * sink" model which libsim had mutated into; | |
29 | * o allow the kernel code to be completely free of code | |
30 | * specifically there to support the user level build. | |
31 | */ | |
32 | ||
f616e2bf DC |
33 | /* |
34 | * define a guard and something we can check to determine what include context | |
35 | * we are running from. | |
36 | */ | |
b626fb59 DC |
37 | #ifndef __LIBXFS_INTERNAL_XFS_H__ |
38 | #define __LIBXFS_INTERNAL_XFS_H__ | |
f616e2bf | 39 | |
3a7e14f9 DW |
40 | /* CONFIG_XFS_* must be defined to 1 to work with IS_ENABLED() */ |
41 | #define CONFIG_XFS_RT 1 | |
42 | #define CONFIG_XFS_BTREE_IN_MEM 1 | |
a8616431 | 43 | |
e515cca1 | 44 | #include "libxfs_api_defs.h" |
6b803e5a | 45 | #include "platform_defs.h" |
dcabd4e7 | 46 | #include "xfs.h" |
b626fb59 | 47 | |
6b803e5a CH |
48 | #include "list.h" |
49 | #include "hlist.h" | |
50 | #include "cache.h" | |
51 | #include "bitops.h" | |
52 | #include "kmem.h" | |
8bf7924e | 53 | #include "libfrog/radix-tree.h" |
03dc2ef2 | 54 | #include "libfrog/bitmask.h" |
af71e8c1 | 55 | #include "libfrog/div64.h" |
1278e817 | 56 | #include "libfrog/util.h" |
6b803e5a | 57 | #include "atomic.h" |
686bddf9 | 58 | #include "spinlock.h" |
128ba9ce | 59 | #include "linux-err.h" |
b626fb59 | 60 | |
6b803e5a CH |
61 | #include "xfs_types.h" |
62 | #include "xfs_arch.h" | |
b626fb59 | 63 | |
6b803e5a | 64 | #include "xfs_fs.h" |
63153a95 | 65 | #include "libfrog/crc32c.h" |
b626fb59 | 66 | |
a392fd5a | 67 | #include <sys/xattr.h> |
2e85cabb DW |
68 | #ifdef HAVE_GETRANDOM_NONBLOCK |
69 | #include <sys/random.h> | |
70 | #endif | |
a392fd5a | 71 | |
4e006361 | 72 | /* Zones used in libxfs allocations that aren't in shared header files */ |
2e1394fc DW |
73 | extern struct kmem_cache *xfs_buf_item_cache; |
74 | extern struct kmem_cache *xfs_ili_cache; | |
75 | extern struct kmem_cache *xfs_buf_cache; | |
76 | extern struct kmem_cache *xfs_inode_cache; | |
77 | extern struct kmem_cache *xfs_trans_cache; | |
4e006361 | 78 | |
75f533e6 | 79 | /* fake up iomap, (not) used in xfs_bmap.[ch] */ |
8b4c5cd1 | 80 | #define IOMAP_F_SHARED 0x04 |
1dcdf505 | 81 | #define xfs_bmbt_to_iomap(a, b, c, d, e, f) ((void) 0) |
75f533e6 | 82 | |
b626fb59 | 83 | /* CRC stuff, buffer API dependent on it */ |
b626fb59 DC |
84 | #define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l)) |
85 | ||
75f533e6 | 86 | /* fake up kernel's iomap, (not) used in xfs_bmap.[ch] */ |
44e4bdc6 ZY |
87 | struct iomap { |
88 | unsigned long long offset; /* do not use */ | |
89 | unsigned long long length; /* do not use */ | |
90 | }; | |
75f533e6 | 91 | |
8804eace ES |
92 | #define cancel_delayed_work_sync(work) do { } while(0) |
93 | ||
6b803e5a | 94 | #include "xfs_cksum.h" |
b626fb59 DC |
95 | |
96 | /* | |
97 | * This mirrors the kernel include for xfs_buf.h - it's implicitly included in | |
98 | * every files via a similar include in the kernel xfs_linux.h. | |
99 | */ | |
897853d5 | 100 | #include "libxfs_io.h" |
b626fb59 DC |
101 | |
102 | /* for all the support code that uses progname in error messages */ | |
103 | extern char *progname; | |
2bd0ea18 | 104 | |
a2ceac1f DC |
105 | #undef ASSERT |
106 | #define ASSERT(ex) assert(ex) | |
5e656dbb | 107 | |
dc9b1f58 CH |
108 | /* |
109 | * We have no need for the "linux" dev_t in userspace, so these | |
110 | * are no-ops, and an xfs_dev_t is stored in VFS_I(ip)->i_rdev | |
111 | */ | |
112 | #define xfs_to_linux_dev_t(dev) dev | |
113 | #define linux_to_xfs_dev_t(dev) dev | |
551174eb | 114 | |
a2ceac1f DC |
115 | #ifndef EWRONGFS |
116 | #define EWRONGFS EINVAL | |
117 | #endif | |
5e656dbb | 118 | |
56b2de80 | 119 | #define xfs_error_level 0 |
5e656dbb BN |
120 | |
121 | #define STATIC static | |
5e656dbb | 122 | |
d7e71605 DW |
123 | /* |
124 | * Starting in Linux 4.15, the %p (raw pointer value) printk modifier | |
125 | * prints a hashed version of the pointer to avoid leaking kernel | |
126 | * pointers into dmesg. If we're trying to debug the kernel we want the | |
127 | * raw values, so override this behavior as best we can. | |
128 | * | |
129 | * In userspace we don't have this problem. | |
130 | */ | |
131 | #define PTR_FMT "%p" | |
132 | ||
5dcd1db5 DC |
133 | #define XFS_IGET_CREATE 0x1 |
134 | #define XFS_IGET_UNTRUSTED 0x2 | |
135 | ||
b626fb59 DC |
136 | extern void cmn_err(int, char *, ...); |
137 | enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; | |
138 | ||
c16edcd7 | 139 | #define xfs_info(mp,fmt,args...) cmn_err(CE_CONT, _(fmt), ## args) |
c8fa782f | 140 | #define xfs_info_ratelimited(mp,fmt,args...) cmn_err(CE_CONT, _(fmt), ## args) |
8faa41b4 | 141 | #define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE, _(fmt), ## args) |
60066f61 | 142 | #define xfs_warn(mp,fmt,args...) cmn_err((mp) ? CE_WARN : CE_WARN, _(fmt), ## args) |
8faa41b4 GX |
143 | #define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) |
144 | #define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) | |
7cf9f816 | 145 | |
a8bbb628 DW |
146 | #define xfs_buf_ioerror_alert(bp,f) ((void) 0); |
147 | ||
b626fb59 | 148 | #define xfs_hex_dump(d,n) ((void) 0) |
8791bf6b ES |
149 | #define xfs_stack_trace() ((void) 0) |
150 | ||
b626fb59 | 151 | |
6f4c54a4 | 152 | #define xfs_force_shutdown(d,n) ((void) 0) |
ac315eaf | 153 | #define xfs_mod_delalloc(a,b,c) ((void) 0) |
7e427bb1 | 154 | #define xfs_mod_sb_delalloc(sb, d) ((void) 0) |
b626fb59 | 155 | |
a2ceac1f | 156 | /* stop unused var warnings by assigning mp to itself */ |
15348e04 | 157 | |
3177b915 | 158 | #define xfs_corruption_error(e,l,mp,b,sz,fi,ln,fa) do { \ |
15348e04 DW |
159 | (mp) = (mp); \ |
160 | cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e)); \ | |
161 | } while (0) | |
162 | ||
3177b915 | 163 | #define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) do { \ |
e0607266 DC |
164 | (mp) = (mp); \ |
165 | cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e)); \ | |
166 | } while (0) | |
167 | ||
168 | #define XFS_ERROR_REPORT(e,l,mp) do { \ | |
169 | (mp) = (mp); \ | |
170 | cmn_err(CE_ALERT, "%s: XFS_ERROR_REPORT", (e)); \ | |
171 | } while (0) | |
172 | ||
fbb4fa7f | 173 | #define XFS_WARN_CORRUPT(mp, expr) \ |
2420d095 | 174 | ( xfs_is_reporting_corruption(mp) ? \ |
fbb4fa7f DW |
175 | (printf("%s: XFS_WARN_CORRUPT at %s:%d", #expr, \ |
176 | __func__, __LINE__), true) : true) | |
177 | ||
178 | #define XFS_IS_CORRUPT(mp, expr) \ | |
179 | (unlikely(expr) ? XFS_WARN_CORRUPT((mp), (expr)) : false) | |
180 | ||
5e656dbb | 181 | #define XFS_ERRLEVEL_LOW 1 |
5e656dbb | 182 | #define XFS_ILOCK_EXCL 0 |
b402af25 | 183 | #define XFS_ILOCK_SHARED 0 |
1be54c61 | 184 | #define XFS_IOLOCK_EXCL 0 |
ece930fa CH |
185 | #define XFS_STATS_INC(mp, count) do { (mp) = (mp); } while (0) |
186 | #define XFS_STATS_DEC(mp, count, x) do { (mp) = (mp); } while (0) | |
187 | #define XFS_STATS_ADD(mp, count, x) do { (mp) = (mp); } while (0) | |
e2a190dd | 188 | #define XFS_TEST_ERROR(expr,a,b) ( expr ) |
5e656dbb | 189 | |
c16edcd7 DW |
190 | #define __section(section) __attribute__((__section__(section))) |
191 | ||
192 | #define xfs_printk_once(func, dev, fmt, ...) \ | |
193 | ({ \ | |
194 | static bool __section(".data.once") __print_once; \ | |
195 | bool __ret_print_once = !__print_once; \ | |
196 | \ | |
197 | if (!__print_once) { \ | |
198 | __print_once = true; \ | |
199 | func(dev, fmt, ##__VA_ARGS__); \ | |
200 | } \ | |
201 | unlikely(__ret_print_once); \ | |
202 | }) | |
203 | ||
204 | #define xfs_info_once(dev, fmt, ...) \ | |
205 | xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__) | |
206 | ||
c1587ecf | 207 | /* Need to be able to handle this bare or in control flow */ |
c08793bd | 208 | static inline bool WARN_ON(bool expr) { |
c1587ecf CH |
209 | return (expr); |
210 | } | |
19ebedcf | 211 | |
c08793bd | 212 | #define WARN_ON_ONCE(e) WARN_ON(e) |
91643efd | 213 | |
cbf3beaa | 214 | #define percpu_counter_read_positive(x) ((*x) > 0 ? (*x) : 0) |
0a0967dd | 215 | #define percpu_counter_sum_positive(x) ((*x) > 0 ? (*x) : 0) |
5e656dbb | 216 | |
2e85cabb DW |
217 | #ifdef HAVE_GETRANDOM_NONBLOCK |
218 | uint32_t get_random_u32(void); | |
219 | #else | |
11d2f5af | 220 | #define get_random_u32() (0) |
2e85cabb | 221 | #endif |
2bd0ea18 | 222 | |
b2327e1a | 223 | #define PAGE_SIZE getpagesize() |
8a044052 | 224 | extern unsigned int PAGE_SHIFT; |
2bd0ea18 | 225 | |
d5105a89 JL |
226 | #define inode_peek_iversion(inode) (inode)->i_version |
227 | #define inode_set_iversion_queried(inode, version) do { \ | |
228 | (inode)->i_version = (version); \ | |
229 | } while (0) | |
230 | ||
fdf7f987 DW |
231 | struct inode; |
232 | struct mnt_idmap; | |
233 | ||
234 | void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode, | |
235 | const struct inode *dir, umode_t mode); | |
236 | ||
5e656dbb BN |
237 | #define min_t(type,x,y) \ |
238 | ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) | |
239 | #define max_t(type,x,y) \ | |
240 | ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) | |
57c9fccb | 241 | |
50c8d191 GS |
242 | /** |
243 | * swap - swap values of @a and @b | |
244 | * @a: first value | |
245 | * @b: second value | |
246 | */ | |
247 | #define swap(a, b) \ | |
248 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) | |
91eba724 | 249 | |
7338c4b8 BF |
250 | #define __round_mask(x, y) ((__typeof__(x))((y)-1)) |
251 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) | |
252 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | |
253 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | |
254 | ||
255 | /* | |
256 | * Handling for kernel bitmap types. | |
257 | */ | |
258 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, NBBY * sizeof(long)) | |
259 | #define DECLARE_BITMAP(name,bits) \ | |
260 | unsigned long name[BITS_TO_LONGS(bits)] | |
261 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) | |
262 | ||
263 | /* | |
264 | * This is a common helper function for find_next_bit and | |
265 | * find_next_zero_bit. The difference is the "invert" argument, which | |
266 | * is XORed with each fetched word before searching it for one bits. | |
267 | */ | |
268 | static inline unsigned long | |
269 | _find_next_bit(const unsigned long *addr, unsigned long nbits, | |
270 | unsigned long start, unsigned long invert) | |
271 | { | |
272 | unsigned long tmp; | |
273 | ||
274 | if (!nbits || start >= nbits) | |
275 | return nbits; | |
276 | ||
277 | tmp = addr[start / BITS_PER_LONG] ^ invert; | |
278 | ||
279 | /* Handle 1st word. */ | |
280 | tmp &= BITMAP_FIRST_WORD_MASK(start); | |
281 | start = round_down(start, BITS_PER_LONG); | |
282 | ||
283 | while (!tmp) { | |
284 | start += BITS_PER_LONG; | |
285 | if (start >= nbits) | |
286 | return nbits; | |
287 | ||
288 | tmp = addr[start / BITS_PER_LONG] ^ invert; | |
289 | } | |
290 | ||
291 | return min(start + ffs(tmp), nbits); | |
292 | } | |
293 | ||
294 | /* | |
295 | * Find the next set bit in a memory region. | |
296 | */ | |
297 | static inline unsigned long | |
298 | find_next_bit(const unsigned long *addr, unsigned long size, | |
299 | unsigned long offset) | |
300 | { | |
301 | return _find_next_bit(addr, size, offset, 0UL); | |
302 | } | |
303 | static inline unsigned long | |
304 | find_next_zero_bit(const unsigned long *addr, unsigned long size, | |
305 | unsigned long offset) | |
306 | { | |
307 | return _find_next_bit(addr, size, offset, ~0UL); | |
308 | } | |
309 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) | |
91eba724 | 310 | |
2bd0ea18 | 311 | /* |
5e656dbb | 312 | * xfs_iroundup: round up argument to next power of two |
2bd0ea18 | 313 | */ |
5e656dbb BN |
314 | static inline uint |
315 | roundup_pow_of_two(uint v) | |
316 | { | |
317 | int i; | |
318 | uint m; | |
319 | ||
320 | if ((v & (v - 1)) == 0) | |
321 | return v; | |
322 | ASSERT((v & 0x80000000) == 0); | |
323 | if ((v & (v + 1)) == 0) | |
324 | return v + 1; | |
325 | for (i = 0, m = 1; i < 31; i++, m <<= 1) { | |
326 | if (v & m) | |
327 | continue; | |
328 | v |= m; | |
329 | if ((v & (v + 1)) == 0) | |
330 | return v + 1; | |
331 | } | |
332 | ASSERT(0); | |
333 | return 0; | |
334 | } | |
2bd0ea18 | 335 | |
5afaf820 DW |
336 | /* If @b is a power of 2, return log2(b). Else return -1. */ |
337 | static inline int8_t log2_if_power2(unsigned long b) | |
338 | { | |
339 | unsigned long mask = 1; | |
340 | unsigned int i; | |
341 | unsigned int ret = 1; | |
342 | ||
343 | if (!is_power_of_2(b)) | |
344 | return -1; | |
345 | ||
346 | for (i = 0; i < NBBY * sizeof(unsigned long); i++, mask <<= 1) { | |
347 | if (b & mask) | |
348 | ret = i; | |
349 | } | |
350 | ||
351 | return ret; | |
352 | } | |
353 | ||
354 | /* If @b is a power of 2, return a mask of the lower bits, else return zero. */ | |
355 | static inline unsigned long long mask64_if_power2(unsigned long b) | |
356 | { | |
357 | return is_power_of_2(b) ? b - 1 : 0; | |
358 | } | |
359 | ||
2bd0ea18 | 360 | /* buffer management */ |
e8a1c983 | 361 | #define XBF_TRYLOCK 0 |
e9d35108 | 362 | #define XBF_DONE 0 |
a2ceac1f | 363 | #define xfs_buf_stale(bp) ((bp)->b_flags |= LIBXFS_B_STALE) |
f1b058f9 | 364 | #define XFS_BUF_UNDELAYWRITE(bp) ((bp)->b_flags &= ~LIBXFS_B_DIRTY) |
5e656dbb | 365 | |
2efa10f3 DC |
366 | /* buffer type flags for write callbacks */ |
367 | #define _XBF_INODES 0 /* inode buffer */ | |
368 | #define _XBF_DQUOTS 0 /* dquot buffer */ | |
369 | #define _XBF_LOGRECOVERY 0 /* log recovery buffer */ | |
370 | ||
0b2f4162 DC |
371 | static inline int |
372 | xfs_buf_incore( | |
373 | struct xfs_buftarg *target, | |
374 | xfs_daddr_t blkno, | |
375 | size_t numblks, | |
376 | xfs_buf_flags_t flags, | |
377 | struct xfs_buf **bpp) | |
d11bffea | 378 | { |
0b2f4162 DC |
379 | *bpp = NULL; |
380 | return -ENOENT; | |
d11bffea CH |
381 | } |
382 | ||
971ce259 | 383 | #define xfs_buf_oneshot(bp) ((void) 0) |
57c9fccb | 384 | |
69806fff CH |
385 | #define xfs_buf_zero(bp, off, len) \ |
386 | memset((bp)->b_addr + off, 0, len); | |
2bd0ea18 | 387 | |
1be76d11 DW |
388 | void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa); |
389 | #define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address) | |
390 | ||
5e656dbb | 391 | /* mount stuff */ |
5e656dbb | 392 | #define xfs_trans_set_sync(tp) ((void) 0) |
6bddecbc DC |
393 | #define xfs_trans_buf_set_type(tp, bp, t) ({ \ |
394 | int __t = (t); \ | |
395 | __t = __t; /* no set-but-unused warning */ \ | |
fca3ed92 | 396 | tp = tp; /* no set-but-unused warning */ \ |
6bddecbc DC |
397 | }) |
398 | ||
8b4dc4a9 | 399 | #define xfs_trans_buf_copy_type(dbp, sbp) |
5e656dbb | 400 | |
d466c866 DW |
401 | static inline void |
402 | xfs_buf_readahead( | |
403 | struct xfs_buftarg *target, | |
404 | xfs_daddr_t blkno, | |
405 | size_t numblks, | |
406 | const struct xfs_buf_ops *ops) | |
407 | { | |
408 | } | |
a2ceac1f | 409 | #define xfs_buf_readahead_map(a,b,c,ops) ((void) 0) /* no readahead */ |
5e656dbb | 410 | |
5e656dbb | 411 | #define xfs_sort qsort |
2bd0ea18 | 412 | |
5e656dbb | 413 | #define xfs_ilock(ip,mode) ((void) 0) |
ff105f75 DC |
414 | #define xfs_ilock_data_map_shared(ip) (0) |
415 | #define xfs_ilock_attr_map_shared(ip) (0) | |
416 | #define xfs_iunlock(ip,mode) ({ \ | |
417 | typeof(mode) __mode = mode; \ | |
418 | __mode = __mode; /* no set-but-unused warning */ \ | |
419 | }) | |
7d6b86ac | 420 | #define xfs_lock_two_inodes(ip0,mode0,ip1,mode1) ((void) 0) |
d3d1a2cb | 421 | #define xfs_assert_ilocked(ip, flags) ((void) 0) |
28fa7241 AH |
422 | #define xfs_lock_inodes(i_tab, nr, mode) ((void) 0) |
423 | #define xfs_sort_inodes(i_tab, nr) ((void) 0) | |
2bd0ea18 | 424 | |
5e656dbb | 425 | /* space allocation */ |
3a13f959 BF |
426 | #define XFS_EXTENT_BUSY_DISCARDED 0x01 /* undergoing a discard op. */ |
427 | #define XFS_EXTENT_BUSY_SKIP_DISCARD 0x02 /* do not discard */ | |
428 | ||
88e008a1 | 429 | #define xfs_extent_busy_reuse(...) ((void) 0) |
aefc06c1 | 430 | /* avoid unused variable warning */ |
63db770a CH |
431 | #define xfs_extent_busy_insert(tp,xg,bno,len,flags)({ \ |
432 | struct xfs_group *__foo = xg; \ | |
aefc06c1 ES |
433 | __foo = __foo; /* no set-but-unused warning */ \ |
434 | }) | |
63db770a | 435 | #define xfs_extent_busy_trim(group,minlen,maxlen,bno,len,busy_gen) ({ \ |
cd80de04 CH |
436 | unsigned __foo = *(busy_gen); \ |
437 | *(busy_gen) = __foo; \ | |
438 | false; \ | |
439 | }) | |
4127f5dc | 440 | #define xfs_extent_busy_flush(tp,pag,busy_gen,alloc_flags) ((int)(0)) |
a2ceac1f | 441 | |
5e656dbb | 442 | #define xfs_rotorstep 1 |
1f2ace68 | 443 | #define xfs_bmap_rtalloc(a) (-ENOSYS) |
5e656dbb BN |
444 | #define xfs_inode_is_filestream(ip) (0) |
445 | #define xfs_filestream_lookup_ag(ip) (0) | |
446 | #define xfs_filestream_new_ag(ip,ag) (0) | |
12ae6818 | 447 | #define xfs_filestream_select_ag(...) (-ENOSYS) |
2bd0ea18 | 448 | |
0f1f6742 DW |
449 | #define xfs_trans_inode_buf(tp, bp) ((void) 0) |
450 | ||
a2ceac1f | 451 | /* quota bits */ |
6d40dad2 CH |
452 | #define xfs_trans_mod_dquot_byino(t,i,f,d) ({ \ |
453 | uint _f = (f); \ | |
454 | _f = _f; /* shut up gcc */ \ | |
455 | }) | |
a2ceac1f | 456 | #define xfs_trans_reserve_quota_nblks(t,i,b,n,f) (0) |
7cd46253 DW |
457 | |
458 | /* hack too silence gcc */ | |
459 | static inline int retzero(void) { return 0; } | |
460 | #define xfs_trans_unreserve_quota_nblks(t,i,b,n,f) retzero() | |
9fcc3af9 | 461 | #define xfs_quota_unreserve_blkres(i,b) retzero() |
7cd46253 | 462 | |
9fcc3af9 DW |
463 | #define xfs_quota_reserve_blkres(i,b) (0) |
464 | #define xfs_qm_dqattach(i) (0) | |
a2ceac1f | 465 | |
5dfa5cd2 DC |
466 | #define uuid_copy(s,d) platform_uuid_copy((s),(d)) |
467 | #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0) | |
468 | ||
e9d35108 | 469 | #define xfs_icreate_log(tp, agno, agbno, cnt, isize, len, gen) ((void) 0) |
4896e6c8 | 470 | #define xfs_sb_validate_fsb_count(sbp, nblks) (0) |
22e2e5e5 | 471 | #define xlog_calc_iovec_len(len) roundup(len, sizeof(uint32_t)) |
e9d35108 | 472 | |
d22f260a CH |
473 | #define xfs_zoned_add_available(mp, rtxnum) do { } while (0) |
474 | ||
2bd0ea18 | 475 | /* |
5e656dbb | 476 | * Prototypes for kernel static functions that are aren't in their |
b626fb59 | 477 | * associated header files. |
2bd0ea18 | 478 | */ |
b626fb59 DC |
479 | struct xfs_da_args; |
480 | struct xfs_bmap_free; | |
481 | struct xfs_bmap_free_item; | |
482 | struct xfs_mount; | |
483 | struct xfs_sb; | |
484 | struct xfs_trans; | |
485 | struct xfs_inode; | |
486 | struct xfs_log_item; | |
487 | struct xfs_buf; | |
488 | struct xfs_buf_map; | |
489 | struct xfs_buf_log_item; | |
490 | struct xfs_buftarg; | |
2bd0ea18 | 491 | |
5e656dbb BN |
492 | /* xfs_attr.c */ |
493 | int xfs_attr_rmtval_get(struct xfs_da_args *); | |
2bd0ea18 NS |
494 | |
495 | /* xfs_bmap.c */ | |
2cf6d225 | 496 | void xfs_bmap_del_free(struct xfs_bmap_free *, struct xfs_bmap_free_item *); |
5e656dbb BN |
497 | |
498 | /* xfs_mount.c */ | |
b626fb59 | 499 | void xfs_mount_common(struct xfs_mount *, struct xfs_sb *); |
5e656dbb BN |
500 | |
501 | /* | |
502 | * logitem.c and trans.c prototypes | |
503 | */ | |
4329aa4c | 504 | void xfs_trans_init(struct xfs_mount *); |
d67406c9 | 505 | int xfs_trans_roll(struct xfs_trans **); |
2bd0ea18 NS |
506 | |
507 | /* xfs_trans_item.c */ | |
c40bdaa2 DC |
508 | void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *); |
509 | void xfs_trans_del_item(struct xfs_log_item *); | |
2bd0ea18 | 510 | |
2bd0ea18 | 511 | /* xfs_inode_item.c */ |
b626fb59 | 512 | void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); |
2bd0ea18 NS |
513 | |
514 | /* xfs_buf_item.c */ | |
b626fb59 DC |
515 | void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); |
516 | void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint); | |
2bd0ea18 | 517 | |
5e656dbb | 518 | /* xfs_trans_buf.c */ |
b626fb59 DC |
519 | struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *, |
520 | struct xfs_buftarg *, struct xfs_buf_map *, int); | |
5e656dbb | 521 | |
2bd0ea18 | 522 | /* local source files */ |
de959abb CH |
523 | #define xfs_add_fdblocks(mp, delta) \ |
524 | libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FDBLOCKS, delta, false) | |
525 | #define xfs_dec_fdblocks(mp, delta, rsvd) \ | |
526 | libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FDBLOCKS, -(int64_t)(delta), rsvd) | |
527 | #define xfs_add_frextents(mp, delta) \ | |
19ebedcf | 528 | libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FREXTENTS, delta, 0) |
de959abb CH |
529 | #define xfs_dec_frextents(mp, delta) \ |
530 | libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FREXTENTS, -(int64_t)(delta), 0) | |
19ebedcf | 531 | int libxfs_mod_incore_sb(struct xfs_mount *, int, int64_t, int); |
2dd13604 ES |
532 | /* percpu counters in mp are #defined to the superblock sb_ counters */ |
533 | #define xfs_reinit_percpu_counters(mp) | |
19ebedcf | 534 | |
b626fb59 | 535 | void xfs_trans_mod_sb(struct xfs_trans *, uint, long); |
15348e04 | 536 | |
1d3bac1f DW |
537 | void xfs_verifier_error(struct xfs_buf *bp, int error, |
538 | xfs_failaddr_t failaddr); | |
539 | void xfs_inode_verifier_error(struct xfs_inode *ip, int error, | |
540 | const char *name, void *buf, size_t bufsz, | |
541 | xfs_failaddr_t failaddr); | |
f616e2bf | 542 | |
43f7ceb5 DW |
543 | #define xfs_buf_verifier_error(bp,e,n,bu,bus,fa) \ |
544 | xfs_verifier_error(bp, e, fa) | |
a0264b73 | 545 | void |
9f09216e | 546 | xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); |
43f7ceb5 | 547 | |
9542ae13 DC |
548 | int libxfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb, |
549 | xfs_off_t count_fsb); | |
550 | ||
4a12ea99 | 551 | /* xfs_log.c */ |
05a3a389 | 552 | struct xfs_item_ops; |
a65d8d29 | 553 | bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t); |
05a3a389 DW |
554 | void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *lip, int type, |
555 | const struct xfs_item_ops *ops); | |
4a12ea99 AH |
556 | #define xfs_attr_use_log_assist(mp) (0) |
557 | #define xlog_drop_incompat_feat(log) do { } while (0) | |
558 | #define xfs_log_in_recovery(mp) (false) | |
a65d8d29 | 559 | |
f7b1a8b1 | 560 | /* xfs_icache.c */ |
829a235c | 561 | #define xfs_inode_clear_cowblocks_tag(ip) do { } while (0) |
9587a34c DW |
562 | #define xfs_inode_set_cowblocks_tag(ip) do { } while (0) |
563 | #define xfs_inode_set_eofblocks_tag(ip) do { } while (0) | |
f7b1a8b1 | 564 | |
5d8acc46 DC |
565 | /* xfs_stats.h */ |
566 | #define XFS_STATS_CALC_INDEX(member) 0 | |
567 | #define XFS_STATS_INC_OFF(mp, off) | |
568 | #define XFS_STATS_ADD_OFF(mp, off, val) | |
569 | ||
4a492e72 | 570 | typedef unsigned char u8; |
c7a710b7 | 571 | unsigned int hweight8(unsigned int w); |
ec291989 DC |
572 | unsigned int hweight32(unsigned int w); |
573 | unsigned int hweight64(__u64 w); | |
5d8acc46 | 574 | |
b944a053 DW |
575 | #define xfs_buf_cache_init(bch) (0) |
576 | #define xfs_buf_cache_destroy(bch) ((void)0) | |
4bcd30f6 DC |
577 | |
578 | static inline int xfs_iunlink_init(struct xfs_perag *pag) { return 0; } | |
579 | static inline void xfs_iunlink_destroy(struct xfs_perag *pag) { } | |
580 | ||
581 | xfs_agnumber_t xfs_set_inode_alloc(struct xfs_mount *mp, | |
582 | xfs_agnumber_t agcount); | |
583 | ||
5f56a561 | 584 | /* Keep static checkers quiet about nonstatic functions by exporting */ |
5f56a561 ES |
585 | /* xfs_bmap_util.h */ |
586 | struct xfs_bmalloca; | |
587 | int xfs_bmap_extsize_align(struct xfs_mount *mp, struct xfs_bmbt_irec *gotp, | |
588 | struct xfs_bmbt_irec *prevp, xfs_extlen_t extsz, | |
589 | int rt, int eof, int delay, int convert, | |
590 | xfs_fileoff_t *offp, xfs_extlen_t *lenp); | |
55d00e3d | 591 | bool xfs_bmap_adjacent(struct xfs_bmalloca *ap); |
5f56a561 ES |
592 | int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip, |
593 | int whichfork, struct xfs_bmbt_irec *rec, | |
594 | int *is_empty); | |
2fdd378a | 595 | |
ed6a3429 CH |
596 | /* xfs_inode.h */ |
597 | #define xfs_iflags_set(ip, flags) do { } while (0) | |
1be54c61 | 598 | #define xfs_finish_inode_setup(ip) ((void) 0) |
ed6a3429 | 599 | |
9f45ce92 DW |
600 | /* linux/wordpart.h */ |
601 | ||
602 | /** | |
603 | * upper_32_bits - return bits 32-63 of a number | |
604 | * @n: the number we're accessing | |
605 | * | |
606 | * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress | |
607 | * the "right shift count >= width of type" warning when that quantity is | |
608 | * 32-bits. | |
609 | */ | |
610 | #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16)) | |
611 | ||
612 | /** | |
613 | * lower_32_bits - return bits 0-31 of a number | |
614 | * @n: the number we're accessing | |
615 | */ | |
616 | #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff)) | |
617 | ||
03a887e4 RHI |
618 | #define cond_resched() ((void)0) |
619 | ||
fdf7f987 DW |
620 | /* xfs_linux.h */ |
621 | #define irix_sgid_inherit (false) | |
622 | #define vfsgid_in_group_p(...) (false) | |
623 | ||
b626fb59 | 624 | #endif /* __LIBXFS_INTERNAL_XFS_H__ */ |