diff options
author | Mark Johnston <markj@FreeBSD.org> | 2018-02-13 19:28:02 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2018-02-13 19:28:02 +0000 |
commit | 6026dcd7ca888f3433f4df34ede69a77c1eb7701 (patch) | |
tree | 0de05c03d3e12526dae1a59da5a95ddedd6c3738 /sys/kern/kern_shutdown.c | |
parent | 83ab0f9f33c1ba96cce50a48e27e40c8c2eead5a (diff) | |
download | src-6026dcd7ca888f3433f4df34ede69a77c1eb7701.tar.gz src-6026dcd7ca888f3433f4df34ede69a77c1eb7701.zip |
Add support for zstd-compressed user and kernel core dumps.
This works similarly to the existing gzip compression support, but
zstd is typically faster and gives better compression ratios.
Support for this functionality must be configured by adding ZSTDIO to
one's kernel configuration file. dumpon(8)'s new -Z option is used to
configure zstd compression for kernel dumps. savecore(8) now recognizes
and saves zstd-compressed kernel dumps with a .zst extension.
Submitted by: cem (original version)
Relnotes: yes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13101,
https://reviews.freebsd.org/D13633
Notes
Notes:
svn path=/head/; revision=329240
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r-- | sys/kern/kern_shutdown.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 0979b3081286..aa60eecc5fa1 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -174,6 +174,7 @@ struct kerneldumpcrypto { #endif struct kerneldumpcomp { + uint8_t kdc_format; struct compressor *kdc_stream; uint8_t *kdc_buf; size_t kdc_resid; @@ -987,12 +988,23 @@ static struct kerneldumpcomp * kerneldumpcomp_create(struct dumperinfo *di, uint8_t compression) { struct kerneldumpcomp *kdcomp; + int format; - if (compression != KERNELDUMP_COMP_GZIP) + switch (compression) { + case KERNELDUMP_COMP_GZIP: + format = COMPRESS_GZIP; + break; + case KERNELDUMP_COMP_ZSTD: + format = COMPRESS_ZSTD; + break; + default: return (NULL); + } + kdcomp = malloc(sizeof(*kdcomp), M_DUMPER, M_WAITOK | M_ZERO); + kdcomp->kdc_format = compression; kdcomp->kdc_stream = compressor_init(kerneldumpcomp_write_cb, - COMPRESS_GZIP, di->maxiosize, kerneldump_gzlevel, di); + format, di->maxiosize, kerneldump_gzlevel, di); if (kdcomp->kdc_stream == NULL) { free(kdcomp, M_DUMPER); return (NULL); @@ -1293,7 +1305,7 @@ dump_start(struct dumperinfo *di, struct kerneldumpheader *kdh) * will occupy, so try to use the whole swap partition * (minus the first 64KB) in the hope that the * compressed dump will fit. If that doesn't turn out to - * be enouch, the bounds checking in dump_write() + * be enough, the bounds checking in dump_write() * will catch us and cause the dump to fail. */ dumpextent = di->mediasize - SIZEOF_METADATA - @@ -1463,7 +1475,7 @@ dump_init_header(const struct dumperinfo *di, struct kerneldumpheader *kdh, if (panicstr != NULL) strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); if (di->kdcomp != NULL) - kdh->compression = KERNELDUMP_COMP_GZIP; + kdh->compression = di->kdcomp->kdc_format; kdh->parity = kerneldump_parity(kdh); } |