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