From: Alexandre Ioffe Date: Thu, 16 Mar 2023 07:25:39 +0000 (-0700) Subject: EX-7013 lipe: printf formats added to lipe_find3 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7d142e6d2427da91137e1b68c182e4b3b13056cf;p=fs%2Flustre-release.git EX-7013 lipe: printf formats added to lipe_find3 Printf formats added to lipe_find3: fid, mirror-count, stripe-count. Sanity-lipe-find3 updated with printf format tests Test-Parameters: trivial testlist=sanity-lipe-find3,sanity-lipe-scan3 Signed-off-by: Alexandre Ioffe Change-Id: Ic5b0d6786c705e51d809eba19e123287d2794740 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/50313 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Colin Faber Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger --- diff --git a/lipe/man/lipe_find3.1 b/lipe/man/lipe_find3.1 index 281aeb7..95b3daa 100644 --- a/lipe/man/lipe_find3.1 +++ b/lipe/man/lipe_find3.1 @@ -273,8 +273,14 @@ Print \fIformat\fP to the standard output, interpreting '\e' escapes and '%' directives. The supported directives include most supported by \fBfind\fP(1) and the following extensions: .RS +.IP %{fid} +file FID .IP %{projid} numerical project ID +.IP %{mirror-count} +FLR mirror count +.IP %{stripe-count} +stripe count of last instantiated component .IP %{xattr:NAME} contents of NAME xattr as a string .RE diff --git a/lipe/src/lipe_find3/lf3_parse_format.c b/lipe/src/lipe_find3/lf3_parse_format.c index 58fb18c..347f09e 100644 --- a/lipe/src/lipe_find3/lf3_parse_format.c +++ b/lipe/src/lipe_find3/lf3_parse_format.c @@ -294,19 +294,14 @@ width: // parent-fid // parent-fids // pools - /* TODO - * if (strcmp(ext, "fid") == 0) - * LF3_EMIT_S('a', "(fid)"); - * else - */ - if (strcmp(ext, "projid") == 0) - LF3_EMIT_N('d', "(%s)", ext); - /* TODO - * else if (strcmp(ext, "projid") == 0 || - * strcmp(ext, "stripe-count") == 0 || - * strcmp(ext, "mirror-count") == 0) - * LF3_EMIT_N('d', "(%s)", ext); - */ + if (strcmp(ext, "fid") == 0) + LF3_EMIT_S('a', "(file-fid)"); + else if (strcmp(ext, "stripe-count") == 0) + LF3_EMIT_N('d', "(lov-stripe-count)", ext); + else if (strcmp(ext, "mirror-count") == 0) + LF3_EMIT_N('d', "(lov-mirror-count)", ext); + else if (strcmp(ext, "projid") == 0) + LF3_EMIT_N('d', "(%s)", ext); else if (strstartswith(ext, "xattr:")) LF3_EMIT_S('a', "(or (xattr-ref-string %Q) %Q)", ext + strlen("xattr:"), ""); else diff --git a/lustre/tests/sanity-lipe-find3.sh b/lustre/tests/sanity-lipe-find3.sh index 4456fbe..6846e03 100644 --- a/lustre/tests/sanity-lipe-find3.sh +++ b/lustre/tests/sanity-lipe-find3.sh @@ -981,6 +981,81 @@ test_115() { } run_test 115 "lipe_find3 -path and -ipath with UTF-8" +test_116() { + local file=$MOUNT/$tfile + declare -a fid + local x + + init_lipe_find3_env + + for x in 1 2 3; do + $LFS mirror create --mirror-count=$x "$file-$x" || + error "cannot create mirror for $file-$x" + fid[${x}]=$($LFS path2fid "$file-"${x}) + done + sync + + for x in 1 2 3; do + expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \ + -mirror-count $x -printf '%{mirror-count} %{fid}' + done + + expect_empty lipe_find3_facet mds1 -mirror-count 4 \ + -printf '%{mirror-count}' + + rm $file* + + for x in 1 2 3; do + $LFS setstripe -i 0 -c $x "$file-1-$x" || + error "cannot setstripe $x for file $file-1-$x" + fid[${x}]=$($LFS path2fid "$file-1-$x") + echo XXX > "$file-1-$x" + done + sync + + for x in 1 2 3; do + expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \ + -stripe-count $x -printf '%{stripe-count} %{fid}' + done + + expect_empty lipe_find3_facet mds1 -stripe-count 4 -printf '%{fid}' + + rm $file* + + for x in 1001 1002 1003; do + touch "$file-2-$x" + $LFS project -p $x $file-2-$x || + error "cannot set project $x for file $file-2-$x" + fid[${x}]=$($LFS path2fid "$file-2-$x") + done + sync + + for x in 1001 1002 1003; do + expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \ + -projid $x -printf '%{projid} %{fid}' + done + + expect_empty lipe_find3_facet mds1 -projid 1 -printf '%{projid} %{fid}' + + rm $file* + + for x in 1 2 3; do + touch "$file-3-$x" + setfattr -n user.$x -v $x "$file-3-$x" + fid[${x}]=$($LFS path2fid "$file-3-$x") + done + sync + + for x in 1 2 3; do + local format='%{xattr:user.'"$x"'} %{fid}' + expect1 "$x ${fid[${x}]}" lipe_find3_facet mds1 \ + -xattr user.$x -printf "${format}" + done + + init_lipe_find3_env +} +run_test 116 "lipe_find3 verify printf formats" + test_130() { local file=$MOUNT/$tfile local xtime