summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-22 17:38:55 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-24 03:03:52 -0500
commita43579380cc201cec8b96de50ae9decfade311cc (patch)
treebc0dd1313df41732ad3b3bf9e9dbb68460a9f6af
parent84afc142937f1dcded97aa2559bbc722c48dce96 (diff)
bcachefs: Add logging for zstd error
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/compress.c5
-rw-r--r--lib/zstd/common/debug.h5
-rw-r--r--lib/zstd/compress/zstd_opt.c12
3 files changed, 18 insertions, 4 deletions
diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index a8b148ec2a2b..4a3ea07cb53d 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -372,8 +372,11 @@ static int attempt_compress(struct bch_fs *c,
dst + 4, dst_len - 4 - 7,
src, src_len,
&c->zstd_params);
- if (zstd_is_error(len))
+ if (zstd_is_error(len)) {
+ bch_err_ratelimited(c, "zstd error: %s %zi, src_len %zu dst_len %zu",
+ zstd_get_error_name(len), len, src_len, dst_len);
return 0;
+ }
*((__le32 *) dst) = cpu_to_le32(len);
return len + 4;
diff --git a/lib/zstd/common/debug.h b/lib/zstd/common/debug.h
index 6dd88d1fbd02..20af9c5aa90b 100644
--- a/lib/zstd/common/debug.h
+++ b/lib/zstd/common/debug.h
@@ -32,6 +32,9 @@
#ifndef DEBUG_H_12987983217
#define DEBUG_H_12987983217
+#include <asm/bug.h>
+#include <asm/string.h>
+
/* static assert is triggered at compile time, leaving no runtime artefact.
@@ -44,7 +47,7 @@
* typically through compiler command line.
* Value must be a number. */
#ifndef DEBUGLEVEL
-# define DEBUGLEVEL 0
+# define DEBUGLEVEL 4
#endif
diff --git a/lib/zstd/compress/zstd_opt.c b/lib/zstd/compress/zstd_opt.c
index fd82acfda62f..bd6f96f7f7db 100644
--- a/lib/zstd/compress/zstd_opt.c
+++ b/lib/zstd/compress/zstd_opt.c
@@ -1127,8 +1127,8 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
for ( ; pos <= end ; pos++ ) {
U32 const matchPrice = ZSTD_getMatchPrice(offcode, pos, optStatePtr, optLevel);
U32 const sequencePrice = literalsPrice + matchPrice;
- DEBUGLOG(7, "rPos:%u => set initial price : %.2f",
- pos, ZSTD_fCost(sequencePrice));
+ //DEBUGLOG(7, "rPos:%u => set initial price : %.2f",
+ // pos, ZSTD_fCost(sequencePrice));
opt[pos].mlen = pos;
opt[pos].off = offcode;
opt[pos].litlen = litlen;
@@ -1152,17 +1152,21 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
- (int)ZSTD_litLengthPrice(litlen-1, optStatePtr, optLevel);
assert(price < 1000000000); /* overflow check */
if (price <= opt[cur].price) {
+#if 0
DEBUGLOG(7, "cPos:%zi==rPos:%u : better price (%.2f<=%.2f) using literal (ll==%u) (hist:%u,%u,%u)",
inr-istart, cur, ZSTD_fCost(price), ZSTD_fCost(opt[cur].price), litlen,
opt[cur-1].rep[0], opt[cur-1].rep[1], opt[cur-1].rep[2]);
+#endif
opt[cur].mlen = 0;
opt[cur].off = 0;
opt[cur].litlen = litlen;
opt[cur].price = price;
} else {
+#if 0
DEBUGLOG(7, "cPos:%zi==rPos:%u : literal would cost more (%.2f>%.2f) (hist:%u,%u,%u)",
inr-istart, cur, ZSTD_fCost(price), ZSTD_fCost(opt[cur].price),
opt[cur].rep[0], opt[cur].rep[1], opt[cur].rep[2]);
+#endif
}
}
@@ -1238,16 +1242,20 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
int const price = (int)basePrice + (int)ZSTD_getMatchPrice(offset, mlen, optStatePtr, optLevel);
if ((pos > last_pos) || (price < opt[pos].price)) {
+#if 0
DEBUGLOG(7, "rPos:%u (ml=%2u) => new better price (%.2f<%.2f)",
pos, mlen, ZSTD_fCost(price), ZSTD_fCost(opt[pos].price));
+#endif
while (last_pos < pos) { opt[last_pos+1].price = ZSTD_MAX_PRICE; last_pos++; } /* fill empty positions */
opt[pos].mlen = mlen;
opt[pos].off = offset;
opt[pos].litlen = litlen;
opt[pos].price = price;
} else {
+#if 0
DEBUGLOG(7, "rPos:%u (ml=%2u) => new price is worse (%.2f>=%.2f)",
pos, mlen, ZSTD_fCost(price), ZSTD_fCost(opt[pos].price));
+#endif
if (optLevel==0) break; /* early update abort; gets ~+10% speed for about -0.01 ratio loss */
}
} } }