]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libxfs/libxfs_priv.h
xfs: refactor log recovery check
[thirdparty/xfsprogs-dev.git] / libxfs / libxfs_priv.h
CommitLineData
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
e515cca1 40#include "libxfs_api_defs.h"
6b803e5a 41#include "platform_defs.h"
dcabd4e7 42#include "xfs.h"
b626fb59 43
6b803e5a
CH
44#include "list.h"
45#include "hlist.h"
46#include "cache.h"
47#include "bitops.h"
48#include "kmem.h"
49#include "radix-tree.h"
50#include "atomic.h"
b626fb59 51
6b803e5a
CH
52#include "xfs_types.h"
53#include "xfs_arch.h"
b626fb59 54
6b803e5a 55#include "xfs_fs.h"
973de649 56#include "crc32c.h"
b626fb59
DC
57
58/* CRC stuff, buffer API dependent on it */
b626fb59
DC
59#define crc32c(c,p,l) crc32c_le((c),(unsigned char const *)(p),(l))
60
6b803e5a 61#include "xfs_cksum.h"
b626fb59
DC
62
63/*
64 * This mirrors the kernel include for xfs_buf.h - it's implicitly included in
65 * every files via a similar include in the kernel xfs_linux.h.
66 */
897853d5 67#include "libxfs_io.h"
b626fb59
DC
68
69/* for all the support code that uses progname in error messages */
70extern char *progname;
2bd0ea18 71
a2ceac1f
DC
72#undef ASSERT
73#define ASSERT(ex) assert(ex)
5e656dbb 74
dc9b1f58
CH
75/*
76 * We have no need for the "linux" dev_t in userspace, so these
77 * are no-ops, and an xfs_dev_t is stored in VFS_I(ip)->i_rdev
78 */
79#define xfs_to_linux_dev_t(dev) dev
80#define linux_to_xfs_dev_t(dev) dev
551174eb 81
a2ceac1f
DC
82#ifndef EWRONGFS
83#define EWRONGFS EINVAL
84#endif
5e656dbb 85
56b2de80 86#define xfs_error_level 0
5e656dbb
BN
87
88#define STATIC static
5e656dbb 89
d7e71605
DW
90/*
91 * Starting in Linux 4.15, the %p (raw pointer value) printk modifier
92 * prints a hashed version of the pointer to avoid leaking kernel
93 * pointers into dmesg. If we're trying to debug the kernel we want the
94 * raw values, so override this behavior as best we can.
95 *
96 * In userspace we don't have this problem.
97 */
98#define PTR_FMT "%p"
99
b626fb59
DC
100/* XXX: need to push these out to make LIBXFS_ATTR defines */
101#define ATTR_ROOT 0x0002
102#define ATTR_SECURE 0x0008
103#define ATTR_CREATE 0x0010
104#define ATTR_REPLACE 0x0020
5e656dbb
BN
105#define ATTR_KERNOTIME 0
106#define ATTR_KERNOVAL 0
107
5dcd1db5
DC
108#define XFS_IGET_CREATE 0x1
109#define XFS_IGET_UNTRUSTED 0x2
110
b626fb59
DC
111extern void cmn_err(int, char *, ...);
112enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
113
114#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE,fmt, ## args)
115#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args)
7cf9f816
DW
116#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args)
117#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args)
118#define xfs_alert_tag(mp,tag,fmt,args...) cmn_err(CE_ALERT,fmt, ## args)
119
b626fb59
DC
120#define xfs_hex_dump(d,n) ((void) 0)
121
6f4c54a4 122#define xfs_force_shutdown(d,n) ((void) 0)
b626fb59 123
a2ceac1f 124/* stop unused var warnings by assigning mp to itself */
15348e04 125
3177b915 126#define xfs_corruption_error(e,l,mp,b,sz,fi,ln,fa) do { \
15348e04
DW
127 (mp) = (mp); \
128 cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e)); \
129} while (0)
130
3177b915 131#define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) do { \
e0607266
DC
132 (mp) = (mp); \
133 cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e)); \
134} while (0)
135
136#define XFS_ERROR_REPORT(e,l,mp) do { \
137 (mp) = (mp); \
138 cmn_err(CE_ALERT, "%s: XFS_ERROR_REPORT", (e)); \
139} while (0)
140
5e656dbb
BN
141#define XFS_ERRLEVEL_LOW 1
142#define XFS_FORCED_SHUTDOWN(mp) 0
143#define XFS_ILOCK_EXCL 0
ece930fa
CH
144#define XFS_STATS_INC(mp, count) do { (mp) = (mp); } while (0)
145#define XFS_STATS_DEC(mp, count, x) do { (mp) = (mp); } while (0)
146#define XFS_STATS_ADD(mp, count, x) do { (mp) = (mp); } while (0)
e2a190dd 147#define XFS_TEST_ERROR(expr,a,b) ( expr )
23639f77
ES
148#define XFS_WANT_CORRUPTED_GOTO(mp, expr, l) \
149{ \
150 if (!(expr)) { \
151 if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED) \
152 printf("WANT_CORRUPTED_GOTO at %s:%d\n", \
153 __func__, __LINE__); \
154 error = -EFSCORRUPTED; \
155 goto l; \
156 } \
157}
158#define XFS_WANT_CORRUPTED_RETURN(mp, expr) \
159{ \
160 if (!(expr)) { \
161 if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED) \
162 printf("WANT_CORRUPTED_RETURN at %s:%d\n", \
163 __func__, __LINE__); \
164 return -EFSCORRUPTED; \
165 } \
166}
5e656dbb 167
5e656dbb
BN
168#ifdef __GNUC__
169#define __return_address __builtin_return_address(0)
b47beff8
DW
170
171/*
172 * Return the address of a label. Use barrier() so that the optimizer
173 * won't reorder code to refactor the error jumpouts into a single
174 * return, which throws off the reported address.
175 */
176#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
177/* Optimization barrier */
178
179/* The "volatile" is due to gcc bugs */
180#define barrier() __asm__ __volatile__("": : :"memory")
181#endif
182
183/* Optimization barrier */
184#ifndef barrier
185# define barrier() __memory_barrier()
5e656dbb
BN
186#endif
187
188/* miscellaneous kernel routines not in user space */
189#define down_read(a) ((void) 0)
190#define up_read(a) ((void) 0)
191#define spin_lock_init(a) ((void) 0)
192#define spin_lock(a) ((void) 0)
193#define spin_unlock(a) ((void) 0)
194#define likely(x) (x)
195#define unlikely(x) (x)
56b2de80
DC
196#define rcu_read_lock() ((void) 0)
197#define rcu_read_unlock() ((void) 0)
c1587ecf
CH
198/* Need to be able to handle this bare or in control flow */
199static inline bool WARN_ON_ONCE(bool expr) {
200 return (expr);
201}
19ebedcf 202
cbf3beaa
GW
203#define percpu_counter_read(x) (*x)
204#define percpu_counter_read_positive(x) ((*x) > 0 ? (*x) : 0)
205#define percpu_counter_sum(x) (*x)
5e656dbb 206
2bd0ea18 207/*
49f693fa 208 * prandom_u32 is used for di_gen inode allocation, it must be zero for libxfs
5e656dbb 209 * or all sorts of badness can occur!
2bd0ea18 210 */
49f693fa 211#define prandom_u32() 0
2bd0ea18 212
b2327e1a 213#define PAGE_SIZE getpagesize()
2bd0ea18 214
d5105a89
JL
215#define inode_peek_iversion(inode) (inode)->i_version
216#define inode_set_iversion_queried(inode, version) do { \
217 (inode)->i_version = (version); \
218} while (0)
219
5e656dbb
BN
220static inline int __do_div(unsigned long long *n, unsigned base)
221{
222 int __res;
223 __res = (int)(((unsigned long) *n) % (unsigned) base);
224 *n = ((unsigned long) *n) / (unsigned) base;
225 return __res;
226}
227
228#define do_div(n,base) (__do_div((unsigned long long *)&(n), (base)))
229#define do_mod(a, b) ((a) % (b))
230#define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
2bd0ea18 231
e91df844
DW
232/**
233 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
234 * @dividend: unsigned 64bit dividend
235 * @divisor: unsigned 32bit divisor
236 * @remainder: pointer to unsigned 32bit remainder
237 *
238 * Return: sets ``*remainder``, then returns dividend / divisor
239 *
240 * This is commonly provided by 32bit archs to provide an optimized 64bit
241 * divide.
242 */
243static inline uint64_t
244div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
245{
246 *remainder = dividend % divisor;
247 return dividend / divisor;
248}
249
5e656dbb
BN
250#define min_t(type,x,y) \
251 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
252#define max_t(type,x,y) \
253 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
57c9fccb 254
50c8d191
GS
255/**
256 * swap - swap values of @a and @b
257 * @a: first value
258 * @b: second value
259 */
260#define swap(a, b) \
261 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
91eba724 262
7338c4b8
BF
263#define __round_mask(x, y) ((__typeof__(x))((y)-1))
264#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
265#define round_down(x, y) ((x) & ~__round_mask(x, y))
266#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
267
268/*
269 * Handling for kernel bitmap types.
270 */
271#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, NBBY * sizeof(long))
272#define DECLARE_BITMAP(name,bits) \
273 unsigned long name[BITS_TO_LONGS(bits)]
274#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
275
276/*
277 * This is a common helper function for find_next_bit and
278 * find_next_zero_bit. The difference is the "invert" argument, which
279 * is XORed with each fetched word before searching it for one bits.
280 */
281static inline unsigned long
282_find_next_bit(const unsigned long *addr, unsigned long nbits,
283 unsigned long start, unsigned long invert)
284{
285 unsigned long tmp;
286
287 if (!nbits || start >= nbits)
288 return nbits;
289
290 tmp = addr[start / BITS_PER_LONG] ^ invert;
291
292 /* Handle 1st word. */
293 tmp &= BITMAP_FIRST_WORD_MASK(start);
294 start = round_down(start, BITS_PER_LONG);
295
296 while (!tmp) {
297 start += BITS_PER_LONG;
298 if (start >= nbits)
299 return nbits;
300
301 tmp = addr[start / BITS_PER_LONG] ^ invert;
302 }
303
304 return min(start + ffs(tmp), nbits);
305}
306
307/*
308 * Find the next set bit in a memory region.
309 */
310static inline unsigned long
311find_next_bit(const unsigned long *addr, unsigned long size,
312 unsigned long offset)
313{
314 return _find_next_bit(addr, size, offset, 0UL);
315}
316static inline unsigned long
317find_next_zero_bit(const unsigned long *addr, unsigned long size,
318 unsigned long offset)
319{
320 return _find_next_bit(addr, size, offset, ~0UL);
321}
322#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
91eba724 323
5e656dbb
BN
324static inline __attribute__((const))
325int is_power_of_2(unsigned long n)
326{
327 return (n != 0 && ((n & (n - 1)) == 0));
328}
2bd0ea18
NS
329
330/*
5e656dbb 331 * xfs_iroundup: round up argument to next power of two
2bd0ea18 332 */
5e656dbb
BN
333static inline uint
334roundup_pow_of_two(uint v)
335{
336 int i;
337 uint m;
338
339 if ((v & (v - 1)) == 0)
340 return v;
341 ASSERT((v & 0x80000000) == 0);
342 if ((v & (v + 1)) == 0)
343 return v + 1;
344 for (i = 0, m = 1; i < 31; i++, m <<= 1) {
345 if (v & m)
346 continue;
347 v |= m;
348 if ((v & (v + 1)) == 0)
349 return v + 1;
350 }
351 ASSERT(0);
352 return 0;
353}
2bd0ea18 354
14f8b681
DW
355static inline uint64_t
356roundup_64(uint64_t x, uint32_t y)
88cd79be
DC
357{
358 x += y - 1;
359 do_div(x, y);
360 return x * y;
361}
362
2bd0ea18 363/* buffer management */
e8a1c983 364#define XBF_TRYLOCK 0
a2ceac1f 365#define XBF_UNMAPPED 0
e9d35108 366#define XBF_DONE 0
a2ceac1f 367#define xfs_buf_stale(bp) ((bp)->b_flags |= LIBXFS_B_STALE)
f1b058f9 368#define XFS_BUF_UNDELAYWRITE(bp) ((bp)->b_flags &= ~LIBXFS_B_DIRTY)
2bd0ea18 369#define XFS_BUF_SET_BDSTRAT_FUNC(a,b) ((void) 0)
5e656dbb 370
9d6fabc0 371/* avoid gcc warning */
ce50fc05 372#define xfs_buf_incore(bt,blkno,len,lockit) ({ \
9d6fabc0 373 typeof(blkno) __foo = (blkno); \
6bddecbc 374 typeof(len) __bar = (len); \
9d6fabc0 375 (blkno) = __foo; \
6bddecbc 376 (len) = __bar; /* no set-but-unused warning */ \
9d6fabc0
DC
377 NULL; \
378})
971ce259
DC
379#define xfs_buf_get_uncached(t,n,f) \
380 libxfs_getbufr((t), XFS_BUF_DADDR_NULL, (n));
2bd0ea18 381#define xfs_buf_relse(bp) libxfs_putbuf(bp)
75c8b434 382#define xfs_buf_get(devp,blkno,len,f) (libxfs_getbuf((devp), (blkno), (len)))
9d6fabc0 383#define xfs_bwrite(bp) libxfs_writebuf((bp), 0)
e9d35108 384#define xfs_buf_delwri_queue(bp, bl) libxfs_writebuf((bp), 0)
971ce259
DC
385#define xfs_buf_delwri_submit(bl) (0)
386#define xfs_buf_oneshot(bp) ((void) 0)
57c9fccb 387
56b2de80
DC
388#define XBRW_READ LIBXFS_BREAD
389#define XBRW_WRITE LIBXFS_BWRITE
390#define xfs_buf_iomove(bp,off,len,data,f) libxfs_iomove(bp,off,len,data,f)
391#define xfs_buf_zero(bp,off,len) libxfs_iomove(bp,off,len,0,LIBXFS_BZERO)
2bd0ea18 392
5e656dbb
BN
393/* mount stuff */
394#define XFS_MOUNT_32BITINODES LIBXFS_MOUNT_32BITINODES
395#define XFS_MOUNT_ATTR2 LIBXFS_MOUNT_ATTR2
396#define XFS_MOUNT_SMALL_INUMS 0 /* ignored in userspace */
397#define XFS_MOUNT_WSYNC 0 /* ignored in userspace */
398#define XFS_MOUNT_NOALIGN 0 /* ignored in userspace */
3439d03a 399#define XFS_MOUNT_IKEEP 0 /* ignored in userspace */
ff105f75
DC
400#define XFS_MOUNT_SWALLOC 0 /* ignored in userspace */
401#define XFS_MOUNT_RDONLY 0 /* ignored in userspace */
52f4e126 402#define XFS_MOUNT_BAD_SUMMARY 0 /* ignored in userspace */
5e656dbb 403
5e656dbb
BN
404#define xfs_trans_set_sync(tp) ((void) 0)
405#define xfs_trans_agblocks_delta(tp, d)
406#define xfs_trans_agflist_delta(tp, d)
407#define xfs_trans_agbtree_delta(tp, d)
6bddecbc
DC
408#define xfs_trans_buf_set_type(tp, bp, t) ({ \
409 int __t = (t); \
410 __t = __t; /* no set-but-unused warning */ \
fca3ed92 411 tp = tp; /* no set-but-unused warning */ \
6bddecbc
DC
412})
413
8b4dc4a9 414#define xfs_trans_buf_copy_type(dbp, sbp)
5e656dbb 415
10851b18
DC
416/* no readahead, need to avoid set-but-unused var warnings. */
417#define xfs_buf_readahead(a,d,c,ops) ({ \
418 xfs_daddr_t __d = d; \
419 __d = __d; /* no set-but-unused warning */ \
420})
a2ceac1f 421#define xfs_buf_readahead_map(a,b,c,ops) ((void) 0) /* no readahead */
5e656dbb 422
5e656dbb 423#define xfs_sort qsort
2bd0ea18 424
5e656dbb 425#define xfs_ilock(ip,mode) ((void) 0)
a2ceac1f
DC
426#define xfs_ilock_nowait(ip,mode) ((void) 0)
427#define xfs_ilock_demote(ip,mode) ((void) 0)
ff105f75
DC
428#define xfs_ilock_data_map_shared(ip) (0)
429#define xfs_ilock_attr_map_shared(ip) (0)
430#define xfs_iunlock(ip,mode) ({ \
431 typeof(mode) __mode = mode; \
432 __mode = __mode; /* no set-but-unused warning */ \
433})
2bd0ea18 434
5e656dbb 435/* space allocation */
3a13f959
BF
436#define XFS_EXTENT_BUSY_DISCARDED 0x01 /* undergoing a discard op. */
437#define XFS_EXTENT_BUSY_SKIP_DISCARD 0x02 /* do not discard */
438
a2ceac1f 439#define xfs_extent_busy_reuse(mp,ag,bno,len,user) ((void) 0)
aefc06c1
ES
440/* avoid unused variable warning */
441#define xfs_extent_busy_insert(tp,ag,bno,len,flags)({ \
442 xfs_agnumber_t __foo = ag; \
443 __foo = __foo; /* no set-but-unused warning */ \
444})
cd80de04
CH
445#define xfs_extent_busy_trim(args,bno,len,busy_gen) ({ \
446 unsigned __foo = *(busy_gen); \
447 *(busy_gen) = __foo; \
448 false; \
449})
b0a898fe 450#define xfs_extent_busy_flush(mp,pag,busy_gen) ((void)(0))
a2ceac1f 451
5e656dbb 452#define xfs_rotorstep 1
1f2ace68 453#define xfs_bmap_rtalloc(a) (-ENOSYS)
5e656dbb 454#define xfs_get_extsz_hint(ip) (0)
10460994 455#define xfs_get_cowextsz_hint(ip) (0)
5e656dbb
BN
456#define xfs_inode_is_filestream(ip) (0)
457#define xfs_filestream_lookup_ag(ip) (0)
458#define xfs_filestream_new_ag(ip,ag) (0)
2bd0ea18 459
a2ceac1f
DC
460#define xfs_log_force(mp,flags) ((void) 0)
461#define XFS_LOG_SYNC 1
462
463/* quota bits */
464#define xfs_trans_mod_dquot_byino(t,i,f,d) ((void) 0)
465#define xfs_trans_reserve_quota_nblks(t,i,b,n,f) (0)
466#define xfs_trans_unreserve_quota_nblks(t,i,b,n,f) ((void) 0)
43cf369d 467#define xfs_qm_dqattach(i) (0)
a2ceac1f 468
5dfa5cd2
DC
469#define uuid_copy(s,d) platform_uuid_copy((s),(d))
470#define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
471
e9d35108 472#define xfs_icreate_log(tp, agno, agbno, cnt, isize, len, gen) ((void) 0)
4896e6c8 473#define xfs_sb_validate_fsb_count(sbp, nblks) (0)
e9d35108 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
479struct xfs_da_args;
480struct xfs_bmap_free;
481struct xfs_bmap_free_item;
482struct xfs_mount;
483struct xfs_sb;
484struct xfs_trans;
485struct xfs_inode;
486struct xfs_log_item;
487struct xfs_buf;
488struct xfs_buf_map;
489struct xfs_buf_log_item;
490struct xfs_buftarg;
2bd0ea18 491
5e656dbb
BN
492/* xfs_attr.c */
493int xfs_attr_rmtval_get(struct xfs_da_args *);
2bd0ea18
NS
494
495/* xfs_bmap.c */
2cf6d225 496void xfs_bmap_del_free(struct xfs_bmap_free *, struct xfs_bmap_free_item *);
5e656dbb
BN
497
498/* xfs_mount.c */
b626fb59
DC
499int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t);
500void xfs_mount_common(struct xfs_mount *, struct xfs_sb *);
5e656dbb
BN
501
502/*
503 * logitem.c and trans.c prototypes
504 */
4329aa4c 505void xfs_trans_init(struct xfs_mount *);
d67406c9 506int xfs_trans_roll(struct xfs_trans **);
2bd0ea18
NS
507
508/* xfs_trans_item.c */
c40bdaa2
DC
509void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
510void xfs_trans_del_item(struct xfs_log_item *);
2bd0ea18 511
2bd0ea18 512/* xfs_inode_item.c */
b626fb59 513void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
2bd0ea18
NS
514
515/* xfs_buf_item.c */
b626fb59
DC
516void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
517void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
2bd0ea18 518
5e656dbb 519/* xfs_trans_buf.c */
b626fb59
DC
520struct xfs_buf *xfs_trans_buf_item_match(struct xfs_trans *,
521 struct xfs_buftarg *, struct xfs_buf_map *, int);
5e656dbb 522
2bd0ea18 523/* local source files */
19ebedcf
DC
524#define xfs_mod_fdblocks(mp, delta, rsvd) \
525 libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FDBLOCKS, delta, rsvd)
526#define xfs_mod_frextents(mp, delta) \
527 libxfs_mod_incore_sb(mp, XFS_TRANS_SB_FREXTENTS, delta, 0)
528int libxfs_mod_incore_sb(struct xfs_mount *, int, int64_t, int);
2dd13604
ES
529/* percpu counters in mp are #defined to the superblock sb_ counters */
530#define xfs_reinit_percpu_counters(mp)
19ebedcf 531
b626fb59 532void xfs_trans_mod_sb(struct xfs_trans *, uint, long);
15348e04 533
1d3bac1f
DW
534void xfs_verifier_error(struct xfs_buf *bp, int error,
535 xfs_failaddr_t failaddr);
536void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
537 const char *name, void *buf, size_t bufsz,
538 xfs_failaddr_t failaddr);
f616e2bf 539
43f7ceb5
DW
540#define xfs_buf_verifier_error(bp,e,n,bu,bus,fa) \
541 xfs_verifier_error(bp, e, fa)
542
b626fb59
DC
543/* XXX: this is clearly a bug - a shared header needs to export this */
544/* xfs_rtalloc.c */
545int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t);
0cf6a3a9 546bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
b626fb59 547
0b10a7f4 548struct xfs_rtalloc_rec {
858ae338
DW
549 xfs_rtblock_t ar_startext;
550 xfs_rtblock_t ar_extcount;
0b10a7f4
DW
551};
552
553typedef int (*xfs_rtalloc_query_range_fn)(
554 struct xfs_trans *tp,
555 struct xfs_rtalloc_rec *rec,
556 void *priv);
557
9542ae13
DC
558int libxfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
559 xfs_off_t count_fsb);
560
d780a2f2 561
a65d8d29 562bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t);
d780a2f2 563#define xfs_log_in_recovery(mp) (false)
a65d8d29 564
f7b1a8b1 565/* xfs_icache.c */
9587a34c
DW
566#define xfs_inode_set_cowblocks_tag(ip) do { } while (0)
567#define xfs_inode_set_eofblocks_tag(ip) do { } while (0)
f7b1a8b1 568
5d8acc46
DC
569/* xfs_stats.h */
570#define XFS_STATS_CALC_INDEX(member) 0
571#define XFS_STATS_INC_OFF(mp, off)
572#define XFS_STATS_ADD_OFF(mp, off, val)
573
4a492e72 574typedef unsigned char u8;
c7a710b7 575unsigned int hweight8(unsigned int w);
ec291989
DC
576unsigned int hweight32(unsigned int w);
577unsigned int hweight64(__u64 w);
5d8acc46 578
2fdd378a
DC
579#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
580#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
581
582static inline void set_bit(int nr, volatile unsigned long *addr)
583{
584 unsigned long mask = BIT_MASK(nr);
585 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
586
587 *p |= mask;
588}
589
590static inline void clear_bit(int nr, volatile unsigned long *addr)
591{
592 unsigned long mask = BIT_MASK(nr);
593 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
594
595 *p &= ~mask;
596}
597
598static inline int test_bit(int nr, const volatile unsigned long *addr)
599{
600 unsigned long mask = BIT_MASK(nr);
601 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
602
603 return *p & mask;
604}
605
606
b626fb59 607#endif /* __LIBXFS_INTERNAL_XFS_H__ */