| .. | .. |
|---|
| 60 | 60 | #include <linux/list_sort.h> |
|---|
| 61 | 61 | #include <linux/ratelimit.h> |
|---|
| 62 | 62 | #include <linux/rhashtable.h> |
|---|
| 63 | +#include <linux/xattr.h> |
|---|
| 63 | 64 | |
|---|
| 64 | 65 | #include <asm/page.h> |
|---|
| 65 | 66 | #include <asm/div64.h> |
|---|
| .. | .. |
|---|
| 101 | 102 | #define xfs_cowb_secs xfs_params.cowb_timer.val |
|---|
| 102 | 103 | |
|---|
| 103 | 104 | #define current_cpu() (raw_smp_processor_id()) |
|---|
| 104 | | -#define current_pid() (current->pid) |
|---|
| 105 | | -#define current_test_flags(f) (current->flags & (f)) |
|---|
| 106 | 105 | #define current_set_flags_nested(sp, f) \ |
|---|
| 107 | 106 | (*(sp) = current->flags, current->flags |= (f)) |
|---|
| 108 | | -#define current_clear_flags_nested(sp, f) \ |
|---|
| 109 | | - (*(sp) = current->flags, current->flags &= ~(f)) |
|---|
| 110 | 107 | #define current_restore_flags_nested(sp, f) \ |
|---|
| 111 | 108 | (current->flags = ((current->flags & ~(f)) | (*(sp) & (f)))) |
|---|
| 112 | | - |
|---|
| 113 | | -#define spinlock_destroy(lock) |
|---|
| 114 | 109 | |
|---|
| 115 | 110 | #define NBBY 8 /* number of bits per byte */ |
|---|
| 116 | 111 | |
|---|
| .. | .. |
|---|
| 128 | 123 | #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ |
|---|
| 129 | 124 | #define EFSBADCRC EBADMSG /* Bad CRC detected */ |
|---|
| 130 | 125 | |
|---|
| 131 | | -#define SYNCHRONIZE() barrier() |
|---|
| 132 | 126 | #define __return_address __builtin_return_address(0) |
|---|
| 133 | 127 | |
|---|
| 134 | 128 | /* |
|---|
| .. | .. |
|---|
| 165 | 159 | |
|---|
| 166 | 160 | extern struct xstats xfsstats; |
|---|
| 167 | 161 | |
|---|
| 168 | | -/* Kernel uid/gid conversion. These are used to convert to/from the on disk |
|---|
| 169 | | - * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally. |
|---|
| 170 | | - * The conversion here is type only, the value will remain the same since we |
|---|
| 171 | | - * are converting to the init_user_ns. The uid is later mapped to a particular |
|---|
| 172 | | - * user namespace value when crossing the kernel/user boundary. |
|---|
| 173 | | - */ |
|---|
| 174 | | -static inline uint32_t xfs_kuid_to_uid(kuid_t uid) |
|---|
| 175 | | -{ |
|---|
| 176 | | - return from_kuid(&init_user_ns, uid); |
|---|
| 177 | | -} |
|---|
| 178 | | - |
|---|
| 179 | | -static inline kuid_t xfs_uid_to_kuid(uint32_t uid) |
|---|
| 180 | | -{ |
|---|
| 181 | | - return make_kuid(&init_user_ns, uid); |
|---|
| 182 | | -} |
|---|
| 183 | | - |
|---|
| 184 | | -static inline uint32_t xfs_kgid_to_gid(kgid_t gid) |
|---|
| 185 | | -{ |
|---|
| 186 | | - return from_kgid(&init_user_ns, gid); |
|---|
| 187 | | -} |
|---|
| 188 | | - |
|---|
| 189 | | -static inline kgid_t xfs_gid_to_kgid(uint32_t gid) |
|---|
| 190 | | -{ |
|---|
| 191 | | - return make_kgid(&init_user_ns, gid); |
|---|
| 192 | | -} |
|---|
| 193 | | - |
|---|
| 194 | 162 | static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) |
|---|
| 195 | 163 | { |
|---|
| 196 | 164 | return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); |
|---|
| .. | .. |
|---|
| 207 | 175 | #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL) |
|---|
| 208 | 176 | #define xfs_stack_trace() dump_stack() |
|---|
| 209 | 177 | |
|---|
| 178 | +static inline uint64_t rounddown_64(uint64_t x, uint32_t y) |
|---|
| 179 | +{ |
|---|
| 180 | + do_div(x, y); |
|---|
| 181 | + return x * y; |
|---|
| 182 | +} |
|---|
| 183 | + |
|---|
| 210 | 184 | static inline uint64_t roundup_64(uint64_t x, uint32_t y) |
|---|
| 211 | 185 | { |
|---|
| 212 | 186 | x += y - 1; |
|---|
| .. | .. |
|---|
| 221 | 195 | return x; |
|---|
| 222 | 196 | } |
|---|
| 223 | 197 | |
|---|
| 198 | +int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count, |
|---|
| 199 | + char *data, unsigned int op); |
|---|
| 200 | + |
|---|
| 224 | 201 | #define ASSERT_ALWAYS(expr) \ |
|---|
| 225 | | - (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) |
|---|
| 202 | + (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) |
|---|
| 226 | 203 | |
|---|
| 227 | 204 | #ifdef DEBUG |
|---|
| 228 | 205 | #define ASSERT(expr) \ |
|---|
| 229 | | - (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) |
|---|
| 206 | + (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) |
|---|
| 230 | 207 | |
|---|
| 231 | 208 | #else /* !DEBUG */ |
|---|
| 232 | 209 | |
|---|
| 233 | 210 | #ifdef XFS_WARN |
|---|
| 234 | 211 | |
|---|
| 235 | 212 | #define ASSERT(expr) \ |
|---|
| 236 | | - (likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__)) |
|---|
| 213 | + (likely(expr) ? (void)0 : asswarn(NULL, #expr, __FILE__, __LINE__)) |
|---|
| 237 | 214 | |
|---|
| 238 | 215 | #else /* !DEBUG && !XFS_WARN */ |
|---|
| 239 | 216 | |
|---|
| 240 | | -#define ASSERT(expr) ((void)0) |
|---|
| 217 | +#define ASSERT(expr) ((void)0) |
|---|
| 241 | 218 | |
|---|
| 242 | 219 | #endif /* XFS_WARN */ |
|---|
| 243 | 220 | #endif /* DEBUG */ |
|---|
| 244 | 221 | |
|---|
| 222 | +#define XFS_IS_CORRUPT(mp, expr) \ |
|---|
| 223 | + (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \ |
|---|
| 224 | + NULL, 0, __FILE__, __LINE__, \ |
|---|
| 225 | + __this_address), \ |
|---|
| 226 | + true : false) |
|---|
| 227 | + |
|---|
| 245 | 228 | #define STATIC static noinline |
|---|
| 246 | 229 | |
|---|
| 247 | 230 | #ifdef CONFIG_XFS_RT |
|---|