From b0404c136240a578655554d37689b47b47ef5920 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Tue, 2 May 2017 14:37:26 +0800 Subject: [PATCH] LU-9369 lfs: make lfs find work correctly This patch resets fp_lmd->lmd_lmm.lmm_magic in case that the previous file's lum is mistakenly used for the next directory in cb_find_init(). This patch also improves sanity.sh test_56s and test_56t to verify the fix. Signed-off-by: Emoly Liu Change-Id: I717ec809ef199be50dd1c4c7e6152ab9aa223f94 Reviewed-on: https://review.whamcloud.com/26914 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 31 ++++++++++++++++++++++++++++++- lustre/utils/liblustreapi.c | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 98d1a05..d797554 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -4852,8 +4852,22 @@ run_test 56r "check lfs find -size works ==========================" test_56s() { # LU-611 TDIR=$DIR/${tdir}s - setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" + #LU-9369 + setup_56 0 $NUMDIRS + for i in $(seq 1 $NUMDIRS); do + $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile + done + EXPECTED=$NUMDIRS + CMD="$LFIND -c $OSTCOUNT $TDIR" + NUMS=$($CMD | wc -l) + [ $NUMS -eq $EXPECTED ] || { + $GETSTRIPE -R $TDIR + error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + } + rm -rf $TDIR + + setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" if [[ $OSTCOUNT -gt 1 ]]; then $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3} ONESTRIPE=4 @@ -4906,6 +4920,21 @@ run_test 56s "check lfs find -stripe-count works" test_56t() { # LU-611 TDIR=$DIR/${tdir}t + + #LU-9369 + setup_56 0 $NUMDIRS + for i in $(seq 1 $NUMDIRS); do + $SETSTRIPE -S 4M $TDIR/dir$i/$tfile + done + EXPECTED=$NUMDIRS + CMD="$LFIND -S 4M $TDIR" + NUMS=$($CMD | wc -l) + [ $NUMS -eq $EXPECTED ] || { + $GETSTRIPE -R $TDIR + error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED" + } + rm -rf $TDIR + setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k" $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3} diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 2226112..06d3702 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3445,6 +3445,8 @@ static int cb_find_init(char *path, DIR *parent, DIR **dirp, if (ret != 0) return ret; } + + param->fp_lmd->lmd_lmm.lmm_magic = 0; ret = get_lmd_info(path, parent, dir, param->fp_lmd, param->fp_lum_size); if (ret == 0 && param->fp_lmd->lmd_lmm.lmm_magic == 0 && -- 1.8.3.1