Skip to content

Commit 03e9d2c

Browse files
committed
ZSTD-DEBUG: Bypass custom allocators only in ASAN userspace builds
Use default malloc in userspace ASAN builds (zloop) to avoid memory fragmentation issues. Custom allocators remain active in kernel and non-ASAN userspace builds to preserve zdb compatibility. This is a TEMPORARY DEBUG commit and must be replaced before merge. Signed-off-by: Alexander Moch <mail@alexmoch.com>
1 parent 76d7600 commit 03e9d2c

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

module/zstd/zfs_zstd.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,26 @@ static const ZSTD_customMem zstd_dctx_malloc = {
199199
NULL,
200200
};
201201

202+
static inline ZSTD_CCtx *
203+
zfs_zstd_createCCtx(void)
204+
{
205+
#if !defined(_KERNEL) && defined(ZFS_ASAN_ENABLED)
206+
return (ZSTD_createCCtx());
207+
#else
208+
return (ZSTD_createCCtx_advanced(zstd_malloc));
209+
#endif
210+
}
211+
212+
static inline ZSTD_DCtx *
213+
zfs_zstd_createDCtx(void)
214+
{
215+
#if !defined(_KERNEL) && defined(ZFS_ASAN_ENABLED)
216+
return (ZSTD_createDCtx());
217+
#else
218+
return (ZSTD_createDCtx_advanced(zstd_dctx_malloc));
219+
#endif
220+
}
221+
202222
/* Level map for converting ZFS internal levels to ZSTD levels and vice versa */
203223
static struct zstd_levelmap zstd_levels[] = {
204224
{ZIO_ZSTD_LEVEL_1, ZIO_ZSTD_LEVEL_1},
@@ -452,7 +472,7 @@ zfs_zstd_compress_impl(void *s_start, void *d_start, size_t s_len, size_t d_len,
452472
ASSERT3U(d_len, <=, s_len);
453473
ASSERT3U(zstd_level, !=, 0);
454474

455-
cctx = ZSTD_createCCtx_advanced(zstd_malloc);
475+
cctx = zfs_zstd_createCCtx();
456476

457477
/*
458478
* Out of kernel memory, gently fall through - this will disable
@@ -646,7 +666,7 @@ zfs_zstd_decompress_level_buf(void *s_start, void *d_start, size_t s_len,
646666
return (1);
647667
}
648668

649-
dctx = ZSTD_createDCtx_advanced(zstd_dctx_malloc);
669+
dctx = zfs_zstd_createDCtx();
650670
if (!dctx) {
651671
ZSTDSTAT_BUMP(zstd_stat_dec_alloc_fail);
652672
return (1);

0 commit comments

Comments
 (0)