aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/include/os/linux/spl
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/include/os/linux/spl')
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h32
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/debug.h4
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h61
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/misc.h6
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/mod.h (renamed from sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h)0
-rw-r--r--sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h2
6 files changed, 49 insertions, 56 deletions
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h b/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
index b2a39d7d6cbf..f4bcd58bd281 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/atomic.h
@@ -71,6 +71,22 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
return ((void *)atomic_cas_64((volatile uint64_t *)target,
(uint64_t)cmp, (uint64_t)newval));
}
+static __inline__ void *
+atomic_swap_ptr(volatile void *target, void *newval)
+{
+ return ((void *)atomic_swap_64((volatile uint64_t *)target,
+ (uint64_t)newval));
+}
+static __inline__ void *
+atomic_load_ptr(volatile void *target)
+{
+ return ((void *)atomic_load_64((volatile uint64_t *)target));
+}
+static __inline__ void
+atomic_store_ptr(volatile void *target, void *newval)
+{
+ atomic_store_64((volatile uint64_t *)target, (uint64_t)newval);
+}
#else /* _LP64 */
static __inline__ void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
@@ -78,6 +94,22 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
return ((void *)atomic_cas_32((volatile uint32_t *)target,
(uint32_t)cmp, (uint32_t)newval));
}
+static __inline__ void *
+atomic_swap_ptr(volatile void *target, void *newval)
+{
+ return ((void *)atomic_swap_32((volatile uint32_t *)target,
+ (uint32_t)newval));
+}
+static __inline__ void *
+atomic_load_ptr(volatile void *target)
+{
+ return ((void *)atomic_load_32((volatile uint32_t *)target));
+}
+static __inline__ void
+atomic_store_ptr(volatile void *target, void *newval)
+{
+ atomic_store_32((volatile uint32_t *)target, (uint32_t)newval);
+}
#endif /* _LP64 */
#endif /* _SPL_ATOMIC_H */
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h b/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
index 1671ba4074da..85b96e1e23a7 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/debug.h
@@ -69,6 +69,10 @@
#define __maybe_unused __attribute__((unused))
#endif
+#ifndef __must_check
+#define __must_check __attribute__((__warn_unused_result__))
+#endif
+
/*
* Without this, we see warnings from objtool during normal Linux builds when
* the kernel is built with CONFIG_STACK_VALIDATION=y:
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h b/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
index 995236117dd4..fe34de9c179e 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/kmem.h
@@ -61,7 +61,7 @@ void *spl_kvmalloc(size_t size, gfp_t flags);
/*
* Convert a KM_* flags mask to its Linux GFP_* counterpart. The conversion
* function is context aware which means that KM_SLEEP allocations can be
- * safely used in syncing contexts which have set PF_FSTRANS.
+ * safely used in syncing contexts which have set SPL_FSTRANS.
*/
static inline gfp_t
kmem_flags_convert(int flags)
@@ -91,25 +91,11 @@ typedef struct {
} fstrans_cookie_t;
/*
- * Introduced in Linux 3.9, however this cannot be solely relied on before
- * Linux 3.18 as it doesn't turn off __GFP_FS as it should.
+ * SPL_FSTRANS is the set of flags that indicate that the task is in a
+ * filesystem or IO codepath, and so any allocation must not call back into
+ * those codepaths (eg to swap).
*/
-#ifdef PF_MEMALLOC_NOIO
-#define __SPL_PF_MEMALLOC_NOIO (PF_MEMALLOC_NOIO)
-#else
-#define __SPL_PF_MEMALLOC_NOIO (0)
-#endif
-
-/*
- * PF_FSTRANS is removed from Linux 4.12
- */
-#ifdef PF_FSTRANS
-#define __SPL_PF_FSTRANS (PF_FSTRANS)
-#else
-#define __SPL_PF_FSTRANS (0)
-#endif
-
-#define SPL_FSTRANS (__SPL_PF_FSTRANS|__SPL_PF_MEMALLOC_NOIO)
+#define SPL_FSTRANS (PF_MEMALLOC_NOIO)
static inline fstrans_cookie_t
spl_fstrans_mark(void)
@@ -141,43 +127,8 @@ spl_fstrans_check(void)
return (current->flags & SPL_FSTRANS);
}
-/*
- * specifically used to check PF_FSTRANS flag, cannot be relied on for
- * checking spl_fstrans_mark().
- */
-static inline int
-__spl_pf_fstrans_check(void)
-{
- return (current->flags & __SPL_PF_FSTRANS);
-}
-
-/*
- * Kernel compatibility for GFP flags
- */
-/* < 4.13 */
-#ifndef __GFP_RETRY_MAYFAIL
-#define __GFP_RETRY_MAYFAIL __GFP_REPEAT
-#endif
-/* < 4.4 */
-#ifndef __GFP_RECLAIM
-#define __GFP_RECLAIM __GFP_WAIT
-#endif
-
-#ifdef HAVE_ATOMIC64_T
-#define kmem_alloc_used_add(size) atomic64_add(size, &kmem_alloc_used)
-#define kmem_alloc_used_sub(size) atomic64_sub(size, &kmem_alloc_used)
-#define kmem_alloc_used_read() atomic64_read(&kmem_alloc_used)
-#define kmem_alloc_used_set(size) atomic64_set(&kmem_alloc_used, size)
extern atomic64_t kmem_alloc_used;
-extern unsigned long long kmem_alloc_max;
-#else /* HAVE_ATOMIC64_T */
-#define kmem_alloc_used_add(size) atomic_add(size, &kmem_alloc_used)
-#define kmem_alloc_used_sub(size) atomic_sub(size, &kmem_alloc_used)
-#define kmem_alloc_used_read() atomic_read(&kmem_alloc_used)
-#define kmem_alloc_used_set(size) atomic_set(&kmem_alloc_used, size)
-extern atomic_t kmem_alloc_used;
-extern unsigned long long kmem_alloc_max;
-#endif /* HAVE_ATOMIC64_T */
+extern uint64_t kmem_alloc_max;
extern unsigned int spl_kmem_alloc_warn;
extern unsigned int spl_kmem_alloc_max;
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h b/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
index 0b44786f8a6e..fbaaf229bd1a 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/misc.h
@@ -24,7 +24,13 @@
#define _OS_LINUX_SPL_MISC_H
#include <linux/kobject.h>
+#include <linux/swap.h>
extern void spl_signal_kobj_evt(struct block_device *bdev);
+/*
+ * Check if the current thread is a memory reclaim thread.
+ */
+extern int current_is_reclaim_thread(void);
+
#endif
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h b/sys/contrib/openzfs/include/os/linux/spl/sys/mod.h
index eaeb9255039e..eaeb9255039e 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/mod_os.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/mod.h
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
index f000f53ab9b6..4eca2414fc5b 100644
--- a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
+++ b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h
@@ -111,7 +111,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
#undef mutex_destroy
#define mutex_destroy(mp) \
{ \
- VERIFY3P(mutex_owner(mp), ==, NULL); \
+ VERIFY0P(mutex_owner(mp)); \
}
#define mutex_tryenter(mp) \