From 8651317d3500d7fb4e45c1d24ff64b4a4c4e3720 Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Wed, 12 Jun 2024 14:54:18 +0100 Subject: [PATCH] EX-9889 csdc: Fix the next available algorithm selection Currently, if a chosen algorithm is not available, then next preferable is chosen, but an error code is not cleared so __alloc_compr() returns this wrong code. Data if written uncompressed while it can be compressed with next appropriate algorithm. This patch adds this error code clearing. Test is provided. Test-Parameters: trivial testlist=sanity-compr env=ONLY=1015,ONLY_REPEAT=10 Signed-off-by: Artem Blagodarenko Fixes: 67794c381440 ("EX-7601 obd: move type switching to alloc_compr callers") Change-Id: I59f65058a0fe9b108de3d4ba7cf5950f18e32204 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55426 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/obdclass/lustre_compr.c | 1 + lustre/tests/sanity-compr.sh | 50 ++++++++++++++++++++++++++++++++++++++++++ lustre/tests/test-framework.sh | 3 +++ 3 files changed, 54 insertions(+) diff --git a/lustre/obdclass/lustre_compr.c b/lustre/obdclass/lustre_compr.c index 7ff0b22..d67f49f 100644 --- a/lustre/obdclass/lustre_compr.c +++ b/lustre/obdclass/lustre_compr.c @@ -221,6 +221,7 @@ static int __alloc_compr(struct client_obd *cli, const char *obdname, load_crypto_module(*type); again: + ret = 0; *cc = crypto_alloc_comp(crypto_name_from_type(*type, *lvl), 0, 0); if (IS_ERR(*cc)) { ret = PTR_ERR(*cc); diff --git a/lustre/tests/sanity-compr.sh b/lustre/tests/sanity-compr.sh index 06c6ea0..7a71590 100644 --- a/lustre/tests/sanity-compr.sh +++ b/lustre/tests/sanity-compr.sh @@ -1375,6 +1375,56 @@ test_1014() { } run_test 1014 "add PFL for compressed layout" +test_1015() { + (( MDS1_VERSION >= $(version_code 2.14.0-ddn153) )) || + skip "Need MDS version at least 2.14.0-ddn153" + + test_mkdir -p $DIR/$tdir + local tf=$DIR/$tdir/$tfile + local hdf=$LUSTRE/tests/AMSR_E_L3_DailyOcean_V05_20111003.hdf + local tmp_hdf=$TMP/$tfile.hdf + local size1 + local size2 + + if [[ ! -f $tmp_hdf ]]; then + if [[ -f $hdf.bz2 ]] && type -p bzcat >/dev/null; then + bzcat $hdf.bz2 > $tmp_hdf + elif [[ -f $hdf.bz2 ]] && type -p bunzip2 >/dev/null; then + cp $hdf.bz2 $tmp_hdf.bz2 || error "cp $tmp_hdf.bz2" + bunzip2 $tmp_hdf.bz2 || error "bunzip2 $tmp_hdf.bz2" + else + skip_env "bunzip2 is not installed" + fi + fi + + size1=$(du -sk $tmp_hdf | awk '{print $1}') + echo "original file size: $size1" + stack_trap "rm -f $tf" + compression_enabled || skip "compression is disabled ($(uname -a))" + + # use lz4:6 compression to force loading llz4hc module + $LFS setstripe -E-1 -c1 -Z lz4:6 --compress-chunk=64 $tf || + error "set a compress component in $tf failed" + cp $tmp_hdf $tf + $TRUNCATE $tf 0 + sync ; sync + + stack_trap "load_module lz4/llz4hc || true" + rmmod llz4hc + + # llz4hc module is unloaded, so a file can not be compressed to lz4:6 + # and lzo algorithm will be chosen + cp $tmp_hdf $tf + sync ; sync + size2=$(du -sk $tf | awk '{print $1}') + echo "compressed file size: $size2" + + (( $size2 < $size1 )) || + error "lz4:6 ($size2) should be less than lz4:3 ($size1)" +} +run_test 1015 "Change lz4hc to lz4fast on fault" + + test_1020() { (( MDS1_VERSION >= $(version_code 2.14.0-ddn128) )) || skip "Need MDS version at least 2.14.0-ddn128" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 59c791a..4b36568 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -10916,6 +10916,9 @@ compression_enabled() { local enabled=($($LCTL get_param -n llite.*.enable_compression)) local supported=($($LCTL get_param -n $facet.*.import | grep -c compress_types)) + # for testing it is useful for the compression_enabled() helper + # to insmod the llz4 and lgzip and lzstd modules to avoid the + # unload problem (( $enabled && $supported )) } -- 1.8.3.1