Whamcloud - gitweb
LU-9369 lfs: make lfs find work correctly 14/26914/2
authorEmoly Liu <emoly.liu@intel.com>
Tue, 2 May 2017 06:37:26 +0000 (14:37 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:47:20 +0000 (03:47 +0000)
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 <emoly.liu@intel.com>
Change-Id: I717ec809ef199be50dd1c4c7e6152ab9aa223f94
Reviewed-on: https://review.whamcloud.com/26914
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index 98d1a05..d797554 100755 (executable)
@@ -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}
index 2226112..06d3702 100644 (file)
@@ -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 &&