Check for __GFP_RECLAIM instead of GFP_KERNEL

Check for __GFP_RECLAIM instead of GFP_KERNEL because zfs modifies
IO and FS flags which breaks the check for GFP_KERNEL.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Closes #9034
This commit is contained in:
Michael Niewöhner 2019-08-06 13:28:56 +02:00 committed by Brian Behlendorf
parent 6d948c3519
commit 8aaa10a9a0

View File

@ -137,6 +137,10 @@ EXPORT_SYMBOL(kmem_strfree);
#ifndef __GFP_RETRY_MAYFAIL #ifndef __GFP_RETRY_MAYFAIL
#define __GFP_RETRY_MAYFAIL __GFP_REPEAT #define __GFP_RETRY_MAYFAIL __GFP_REPEAT
#endif #endif
/* Kernel compatibility for <4.4 */
#ifndef __GFP_RECLAIM
#define __GFP_RECLAIM __GFP_WAIT
#endif
void * void *
spl_kvmalloc(size_t size, gfp_t lflags) spl_kvmalloc(size_t size, gfp_t lflags)
@ -186,14 +190,15 @@ spl_kvmalloc(size_t size, gfp_t lflags)
* We first try kmalloc - even for big sizes - and fall back to * We first try kmalloc - even for big sizes - and fall back to
* __vmalloc if that fails. * __vmalloc if that fails.
* *
* For non-GFP_KERNEL allocations we always stick to kmalloc_node, * For non-__GFP-RECLAIM allocations we always stick to
* and fail when kmalloc is not successful (returns NULL). * kmalloc_node, and fail when kmalloc is not successful (returns
* NULL).
* We cannot fall back to __vmalloc in this case because __vmalloc * We cannot fall back to __vmalloc in this case because __vmalloc
* internally uses GPF_KERNEL allocations. * internally uses GPF_KERNEL allocations.
*/ */
void *ptr = kmalloc_node(size, kmalloc_lflags, NUMA_NO_NODE); void *ptr = kmalloc_node(size, kmalloc_lflags, NUMA_NO_NODE);
if (ptr || size <= PAGE_SIZE || if (ptr || size <= PAGE_SIZE ||
(lflags & GFP_KERNEL) != GFP_KERNEL) { (lflags & __GFP_RECLAIM) != __GFP_RECLAIM) {
return (ptr); return (ptr);
} }