Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Feb 2020 23:53:49 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358187 - head/sys/kern
Message-ID:  <202002202353.01KNrnBO099280@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Thu Feb 20 23:53:48 2020
New Revision: 358187
URL: https://svnweb.freebsd.org/changeset/base/358187

Log:
  clamp kernel dump compression level when using gzip
  
  If the configured compression level for kernel dumps
  it outside the supported range, clamp it to the closest
  supported level.  Previously, dumpon would fail.
  
  zstd already does this internally, so the compressor
  needs no change.
  
  Reviewed by:	cem markj
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D23765

Modified:
  head/sys/kern/subr_compressor.c

Modified: head/sys/kern/subr_compressor.c
==============================================================================
--- head/sys/kern/subr_compressor.c	Thu Feb 20 23:47:09 2020	(r358186)
+++ head/sys/kern/subr_compressor.c	Thu Feb 20 23:53:48 2020	(r358187)
@@ -117,6 +117,13 @@ gz_init(size_t maxiosize, int level)
 	s->gz_stream.next_in = Z_NULL;
 	s->gz_stream.avail_in = 0;
 
+	if (level != Z_DEFAULT_COMPRESSION) {
+		if (level < Z_BEST_SPEED)
+			level = Z_BEST_SPEED;
+		else if (level > Z_BEST_COMPRESSION)
+			level = Z_BEST_COMPRESSION;
+	}
+
 	error = deflateInit2(&s->gz_stream, level, Z_DEFLATED, -MAX_WBITS,
 	    DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
 	if (error != 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002202353.01KNrnBO099280>