Skip to content

Commit

Permalink
linux/spl/kmem_cache: undefine kmem_cache_alloc before defining it
Browse files Browse the repository at this point in the history
When compiling a kernel with bcachefs and zfs, the two macros will collide, making it impossible
to have both filesystems.

It is sufficient to just undefine the macro before calling it.

On why this should be in ZFS rather than bcachefs, currently, bcachefs is not a in-tree filesystem, but,
it has a reasonably high chance of getting included soon.

This avoids the breakage in ZFS early, this patch may be distributed downstream in NixOS and is already used there.
  • Loading branch information
RaitoBezarius committed Aug 2, 2023
1 parent 1abf68b commit ec641e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/os/linux/spl/sys/kmem_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ extern uint64_t spl_kmem_cache_entry_size(kmem_cache_t *cache);
spl_kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl)
#define kmem_cache_set_move(skc, move) spl_kmem_cache_set_move(skc, move)
#define kmem_cache_destroy(skc) spl_kmem_cache_destroy(skc)
/*
* This is necessary to be compatible with other kernel modules
* or in-tree filesystem that may define kmem_cache_alloc,
* like bcachefs does it now.
*/
#undef kmem_cache_alloc
#define kmem_cache_alloc(skc, flags) spl_kmem_cache_alloc(skc, flags)
#define kmem_cache_free(skc, obj) spl_kmem_cache_free(skc, obj)
#define kmem_cache_reap_now(skc) spl_kmem_cache_reap_now(skc)
Expand Down

0 comments on commit ec641e5

Please sign in to comment.