Skip to content

Instantly share code, notes, and snippets.

@tuxoko
Created April 16, 2014 08:32
Show Gist options
  • Save tuxoko/10832862 to your computer and use it in GitHub Desktop.
Save tuxoko/10832862 to your computer and use it in GitHub Desktop.
diff --git a/module/zfs/zio.c b/module/zfs/zio.c
index 8f8d86f..be3f97b 100644
--- a/module/zfs/zio.c
+++ b/module/zfs/zio.c
@@ -263,7 +263,10 @@ zio_buf_alloc(size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
+ if (size <= 8192)
+ return kmalloc(size, GFP_NOIO);
+#endif
return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE | KM_NODEBUG));
}
@@ -279,7 +282,10 @@ zio_data_buf_alloc(size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
+ if (size <= 8192)
+ return kmalloc(size, GFP_NOIO);
+#endif
return (kmem_cache_alloc(zio_data_buf_cache[c],
KM_PUSHPAGE | KM_NODEBUG));
}
@@ -290,7 +296,12 @@ zio_buf_free(void *buf, size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
+ if (size <= 8192) {
+ kfree(buf);
+ return;
+ }
+#endif
kmem_cache_free(zio_buf_cache[c], buf);
}
@@ -300,7 +311,12 @@ zio_data_buf_free(void *buf, size_t size)
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
-
+#ifdef _KERNEL
+ if (size <= 8192) {
+ kfree(buf);
+ return;
+ }
+#endif
kmem_cache_free(zio_data_buf_cache[c], buf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment