From: Sebastien Buisson Date: Wed, 21 Jun 2023 11:07:36 +0000 (+0000) Subject: EX-7714 utils: logical AND for 'lfs find' compression exprs X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b6b4f89f0196a77874350fa44e9891a84ffe8a4b;p=fs%2Flustre-release.git EX-7714 utils: logical AND for 'lfs find' compression exprs All search expressions provided to 'lfs find' must be combined as a logical AND. Fix newly added options for compression support, so that they comply with this logical AND. Fixes: 093bd2f343 ("EX-6856 utils: add 'lfs find' support for compressed file") Signed-off-by: Sebastien Buisson Change-Id: I3b28cd87c1d304df6d04753b413d46f5abcfe16e Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51393 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index d8f9a00..48f7e9c 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -2709,6 +2709,20 @@ test_100d() { error "found $found compress level -$lvl file != $expect" done + # test combination of compr type and compr level + flg_opts="--compr-type=gzip --compr-level=1" + found=$($LFS find $flg_opts $DIR/$tdir | wc -l) + (( $found == 1 )) || + error "found $found compress type gzip level 1 files != 1" + flg_opts="--compr-type=gzip ! --compr-level=1" + found=$($LFS find $flg_opts $DIR/$tdir | wc -l) + (( $found == 0 )) || + error "found $found compress type gzip ! level 1 files != 0" + flg_opts="--compr-type=gzip --compr-level=2" + found=$($LFS find $flg_opts $DIR/$tdir | wc -l) + (( $found == 0 )) || + error "found $found compress type gzip level 2 files != 0" + cs="64 128 256 512" local i=1 for chunk in $cs; do diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 8dc5dbb..7575ba8 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -4364,6 +4364,7 @@ static int find_check_compress(struct find_param *param) int i, j; bool valid = false; bool found_type = false, found_lvl = false, found_chunk = false; + bool found; unsigned long long val; if (v1->lmm_magic != LOV_USER_MAGIC_COMP_V1) @@ -4373,6 +4374,7 @@ static int find_check_compress(struct find_param *param) for (i = 0; i < comp_v1->lcm_entry_count; i++) { entry = &comp_v1->lcm_entries[i]; + found = true; /** * if it's not a compress file, don't count it as a valid @@ -4431,27 +4433,33 @@ static int find_check_compress(struct find_param *param) } } - if ((param->fp_check_compr_type && found_type) || - (param->fp_check_compr_lvl && found_lvl) || - (param->fp_check_compr_chunk && found_chunk)) + if (param->fp_check_compr_type && !found_type) + found = false; + if (param->fp_check_compr_lvl && !found_lvl) + found = false; + if (param->fp_check_compr_chunk && !found_chunk) + found = false; + + if (found) break; } if (!valid) return -1; + found = true; if (param->fp_check_compr_type && - ((found_type && !param->fp_exclude_compr_type) || - (!found_type && param->fp_exclude_compr_type))) - return 1; + ((!found_type && !param->fp_exclude_compr_type) || + (found_type && param->fp_exclude_compr_type))) + found = false; - if (param->fp_check_compr_lvl && found_lvl) - return 1; + if (param->fp_check_compr_lvl && !found_lvl) + found = false; - if (param->fp_check_compr_chunk && found_chunk) - return 1; + if (param->fp_check_compr_chunk && !found_chunk) + found = false; - return -1; + return found ? 1 : -1; } #define LOV_PATTERN_INVALID 0xFFFFFFFF