0001
0002
0003
0004
0005
0006 #ifndef __XFS_LINUX__
0007 #define __XFS_LINUX__
0008
0009 #include <linux/types.h>
0010 #include <linux/uuid.h>
0011
0012
0013
0014
0015
0016 typedef __s64 xfs_off_t;
0017 typedef unsigned long long xfs_ino_t;
0018 typedef __s64 xfs_daddr_t;
0019 typedef __u32 xfs_dev_t;
0020 typedef __u32 xfs_nlink_t;
0021
0022 #include "xfs_types.h"
0023
0024 #include "kmem.h"
0025 #include "mrlock.h"
0026
0027 #include <linux/semaphore.h>
0028 #include <linux/mm.h>
0029 #include <linux/sched/mm.h>
0030 #include <linux/kernel.h>
0031 #include <linux/blkdev.h>
0032 #include <linux/slab.h>
0033 #include <linux/crc32c.h>
0034 #include <linux/module.h>
0035 #include <linux/mutex.h>
0036 #include <linux/file.h>
0037 #include <linux/swap.h>
0038 #include <linux/errno.h>
0039 #include <linux/sched/signal.h>
0040 #include <linux/bitops.h>
0041 #include <linux/major.h>
0042 #include <linux/pagemap.h>
0043 #include <linux/vfs.h>
0044 #include <linux/seq_file.h>
0045 #include <linux/init.h>
0046 #include <linux/list.h>
0047 #include <linux/proc_fs.h>
0048 #include <linux/sort.h>
0049 #include <linux/cpu.h>
0050 #include <linux/notifier.h>
0051 #include <linux/delay.h>
0052 #include <linux/log2.h>
0053 #include <linux/spinlock.h>
0054 #include <linux/random.h>
0055 #include <linux/ctype.h>
0056 #include <linux/writeback.h>
0057 #include <linux/capability.h>
0058 #include <linux/kthread.h>
0059 #include <linux/freezer.h>
0060 #include <linux/list_sort.h>
0061 #include <linux/ratelimit.h>
0062 #include <linux/rhashtable.h>
0063 #include <linux/xattr.h>
0064 #include <linux/mnt_idmapping.h>
0065
0066 #include <asm/page.h>
0067 #include <asm/div64.h>
0068 #include <asm/param.h>
0069 #include <linux/uaccess.h>
0070 #include <asm/byteorder.h>
0071 #include <asm/unaligned.h>
0072
0073 #include "xfs_fs.h"
0074 #include "xfs_stats.h"
0075 #include "xfs_sysctl.h"
0076 #include "xfs_iops.h"
0077 #include "xfs_aops.h"
0078 #include "xfs_super.h"
0079 #include "xfs_cksum.h"
0080 #include "xfs_buf.h"
0081 #include "xfs_message.h"
0082
0083 #ifdef __BIG_ENDIAN
0084 #define XFS_NATIVE_HOST 1
0085 #else
0086 #undef XFS_NATIVE_HOST
0087 #endif
0088
0089 #define irix_sgid_inherit xfs_params.sgid_inherit.val
0090 #define irix_symlink_mode xfs_params.symlink_mode.val
0091 #define xfs_panic_mask xfs_params.panic_mask.val
0092 #define xfs_error_level xfs_params.error_level.val
0093 #define xfs_syncd_centisecs xfs_params.syncd_timer.val
0094 #define xfs_stats_clear xfs_params.stats_clear.val
0095 #define xfs_inherit_sync xfs_params.inherit_sync.val
0096 #define xfs_inherit_nodump xfs_params.inherit_nodump.val
0097 #define xfs_inherit_noatime xfs_params.inherit_noatim.val
0098 #define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
0099 #define xfs_rotorstep xfs_params.rotorstep.val
0100 #define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val
0101 #define xfs_fstrm_centisecs xfs_params.fstrm_timer.val
0102 #define xfs_blockgc_secs xfs_params.blockgc_timer.val
0103
0104 #define current_cpu() (raw_smp_processor_id())
0105 #define current_set_flags_nested(sp, f) \
0106 (*(sp) = current->flags, current->flags |= (f))
0107 #define current_restore_flags_nested(sp, f) \
0108 (current->flags = ((current->flags & ~(f)) | (*(sp) & (f))))
0109
0110 #define NBBY 8
0111
0112
0113
0114
0115
0116 #define BLKDEV_IOSHIFT PAGE_SHIFT
0117 #define BLKDEV_IOSIZE (1<<BLKDEV_IOSHIFT)
0118
0119 #define BLKDEV_BB BTOBB(BLKDEV_IOSIZE)
0120
0121 #define ENOATTR ENODATA
0122 #define EWRONGFS EINVAL
0123 #define EFSCORRUPTED EUCLEAN
0124 #define EFSBADCRC EBADMSG
0125
0126 #define __return_address __builtin_return_address(0)
0127
0128
0129
0130
0131
0132
0133 #define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
0134
0135 #define XFS_PROJID_DEFAULT 0
0136
0137 #define howmany(x, y) (((x)+((y)-1))/(y))
0138
0139 static inline void delay(long ticks)
0140 {
0141 schedule_timeout_uninterruptible(ticks);
0142 }
0143
0144
0145
0146
0147
0148
0149
0150 struct xfs_kobj {
0151 struct kobject kobject;
0152 struct completion complete;
0153 };
0154
0155 struct xstats {
0156 struct xfsstats __percpu *xs_stats;
0157 struct xfs_kobj xs_kobj;
0158 };
0159
0160 extern struct xstats xfsstats;
0161
0162 static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev)
0163 {
0164 return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
0165 }
0166
0167 static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)
0168 {
0169 return sysv_encode_dev(dev);
0170 }
0171
0172
0173
0174
0175 #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
0176 #define xfs_stack_trace() dump_stack()
0177
0178 static inline uint64_t rounddown_64(uint64_t x, uint32_t y)
0179 {
0180 do_div(x, y);
0181 return x * y;
0182 }
0183
0184 static inline uint64_t roundup_64(uint64_t x, uint32_t y)
0185 {
0186 x += y - 1;
0187 do_div(x, y);
0188 return x * y;
0189 }
0190
0191 static inline uint64_t howmany_64(uint64_t x, uint32_t y)
0192 {
0193 x += y - 1;
0194 do_div(x, y);
0195 return x;
0196 }
0197
0198 int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
0199 char *data, enum req_op op);
0200
0201 #define ASSERT_ALWAYS(expr) \
0202 (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
0203
0204 #ifdef DEBUG
0205 #define ASSERT(expr) \
0206 (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
0207
0208 #else
0209
0210 #ifdef XFS_WARN
0211
0212 #define ASSERT(expr) \
0213 (likely(expr) ? (void)0 : asswarn(NULL, #expr, __FILE__, __LINE__))
0214
0215 #else
0216
0217 #define ASSERT(expr) ((void)0)
0218
0219 #endif
0220 #endif
0221
0222 #define XFS_IS_CORRUPT(mp, expr) \
0223 (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \
0224 NULL, 0, __FILE__, __LINE__, \
0225 __this_address), \
0226 true : false)
0227
0228 #define STATIC static noinline
0229
0230 #ifdef CONFIG_XFS_RT
0231
0232
0233
0234
0235
0236 #define XFS_IS_REALTIME_INODE(ip) \
0237 (((ip)->i_diflags & XFS_DIFLAG_REALTIME) && \
0238 (ip)->i_mount->m_rtdev_targp)
0239 #define XFS_IS_REALTIME_MOUNT(mp) ((mp)->m_rtdev_targp ? 1 : 0)
0240 #else
0241 #define XFS_IS_REALTIME_INODE(ip) (0)
0242 #define XFS_IS_REALTIME_MOUNT(mp) (0)
0243 #endif
0244
0245
0246
0247
0248
0249
0250
0251 #ifdef DEBUG
0252 # define PTR_FMT "%px"
0253 #else
0254 # define PTR_FMT "%p"
0255 #endif
0256
0257 #endif