^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2000-2005 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __XFS_LINUX__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __XFS_LINUX__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/uuid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Kernel specific type declarations for XFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) typedef __s64 xfs_off_t; /* <file offset> type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) typedef unsigned long long xfs_ino_t; /* <inode> type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) typedef __s64 xfs_daddr_t; /* <disk address> type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) typedef __u32 xfs_dev_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) typedef __u32 xfs_nlink_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "xfs_types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "kmem.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "mrlock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/semaphore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/crc32c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/swap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/major.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/sort.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include <linux/log2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <linux/writeback.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #include <linux/capability.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include <linux/list_sort.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include <linux/ratelimit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #include <linux/rhashtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #include <asm/div64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #include <asm/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #include "xfs_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #include "xfs_stats.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #include "xfs_sysctl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #include "xfs_iops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #include "xfs_aops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #include "xfs_super.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #include "xfs_cksum.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #include "xfs_buf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #include "xfs_message.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define XFS_NATIVE_HOST 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #undef XFS_NATIVE_HOST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define irix_sgid_inherit xfs_params.sgid_inherit.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define irix_symlink_mode xfs_params.symlink_mode.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define xfs_panic_mask xfs_params.panic_mask.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define xfs_error_level xfs_params.error_level.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define xfs_syncd_centisecs xfs_params.syncd_timer.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define xfs_stats_clear xfs_params.stats_clear.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define xfs_inherit_sync xfs_params.inherit_sync.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define xfs_inherit_nodump xfs_params.inherit_nodump.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define xfs_inherit_noatime xfs_params.inherit_noatim.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define xfs_rotorstep xfs_params.rotorstep.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define xfs_fstrm_centisecs xfs_params.fstrm_timer.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define xfs_eofb_secs xfs_params.eofb_timer.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define xfs_cowb_secs xfs_params.cowb_timer.val
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define current_cpu() (raw_smp_processor_id())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define current_set_flags_nested(sp, f) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) (*(sp) = current->flags, current->flags |= (f))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define current_restore_flags_nested(sp, f) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) (current->flags = ((current->flags & ~(f)) | (*(sp) & (f))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define NBBY 8 /* number of bits per byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * Size of block device i/o is parameterized here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * Currently the system supports page-sized i/o.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define BLKDEV_IOSHIFT PAGE_SHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define BLKDEV_IOSIZE (1<<BLKDEV_IOSHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* number of BB's per block device block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define BLKDEV_BB BTOBB(BLKDEV_IOSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define ENOATTR ENODATA /* Attribute not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define EWRONGFS EINVAL /* Mount with wrong filesystem type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define EFSBADCRC EBADMSG /* Bad CRC detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define __return_address __builtin_return_address(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Return the address of a label. Use barrier() so that the optimizer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * won't reorder code to refactor the error jumpouts into a single
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * return, which throws off the reported address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define XFS_PROJID_DEFAULT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define howmany(x, y) (((x)+((y)-1))/(y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static inline void delay(long ticks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) schedule_timeout_uninterruptible(ticks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * XFS wrapper structure for sysfs support. It depends on external data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * structures and is embedded in various internal data structures to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * the XFS sysfs object heirarchy. Define it here for broad access throughout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * the codebase.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct xfs_kobj {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct kobject kobject;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct completion complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct xstats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct xfsstats __percpu *xs_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct xfs_kobj xs_kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) extern struct xstats xfsstats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return sysv_encode_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * Various platform dependent calls that don't fit anywhere else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #define xfs_stack_trace() dump_stack()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static inline uint64_t rounddown_64(uint64_t x, uint32_t y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) do_div(x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return x * y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static inline uint64_t roundup_64(uint64_t x, uint32_t y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) x += y - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) do_div(x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return x * y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static inline uint64_t howmany_64(uint64_t x, uint32_t y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) x += y - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) do_div(x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) char *data, unsigned int op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define ASSERT_ALWAYS(expr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #define ASSERT(expr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #else /* !DEBUG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #ifdef XFS_WARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #define ASSERT(expr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) (likely(expr) ? (void)0 : asswarn(NULL, #expr, __FILE__, __LINE__))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #else /* !DEBUG && !XFS_WARN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #define ASSERT(expr) ((void)0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #endif /* XFS_WARN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif /* DEBUG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #define XFS_IS_CORRUPT(mp, expr) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) NULL, 0, __FILE__, __LINE__, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) __this_address), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) true : false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #define STATIC static noinline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #ifdef CONFIG_XFS_RT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * make sure we ignore the inode flag if the filesystem doesn't have a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * configured realtime device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #define XFS_IS_REALTIME_INODE(ip) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) (ip)->i_mount->m_rtdev_targp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #define XFS_IS_REALTIME_INODE(ip) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define XFS_IS_REALTIME_MOUNT(mp) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * Starting in Linux 4.15, the %p (raw pointer value) printk modifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * prints a hashed version of the pointer to avoid leaking kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * pointers into dmesg. If we're trying to debug the kernel we want the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * raw values, so override this behavior as best we can.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) # define PTR_FMT "%px"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) # define PTR_FMT "%p"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #endif /* __XFS_LINUX__ */