]> git.proxmox.com Git - mirror_spl.git/blobdiff - include/sys/kmem.h
Add hooks for disabling direct reclaim
[mirror_spl.git] / include / sys / kmem.h
index 045d07c2c706f9681bd47c01885a77c82234d752..8d5e729373fa265a14f393280df89d2aecbed9b3 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef _SPL_KMEM_H
 #define        _SPL_KMEM_H
 
+#include <sys/debug.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
 
@@ -72,6 +73,39 @@ kmem_flags_convert(int flags)
        return (lflags);
 }
 
+typedef struct {
+       struct task_struct *fstrans_thread;
+       unsigned int saved_flags;
+} fstrans_cookie_t;
+
+static inline fstrans_cookie_t
+spl_fstrans_mark(void)
+{
+       fstrans_cookie_t cookie;
+
+       cookie.fstrans_thread = current;
+       cookie.saved_flags = current->flags & PF_FSTRANS;
+       current->flags |= PF_FSTRANS;
+
+       return (cookie);
+}
+
+static inline void
+spl_fstrans_unmark(fstrans_cookie_t cookie)
+{
+       ASSERT3P(cookie.fstrans_thread, ==, current);
+       ASSERT(current->flags & PF_FSTRANS);
+
+       current->flags &= ~(PF_FSTRANS);
+       current->flags |= cookie.saved_flags;
+}
+
+static inline int
+spl_fstrans_check(void)
+{
+       return (current->flags & PF_FSTRANS);
+}
+
 #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)