Whamcloud - gitweb
LU-9341 utils: fix lfs find for composite files 11/35611/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 25 Jul 2019 05:29:26 +0000 (23:29 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 9 Aug 2019 04:39:41 +0000 (04:39 +0000)
Running "lfs getstripe -c" on a composite file returns the stripe
count of the last initialized component, but "lfs find -c N" does
not find this file because it was adding the total stripe_count
of all components.  "lfs find" should also check the stripe_count
of the last initialized component, as described in the man page.
Also use the last component stripe_size instead of any component.

Add a test case for the correct usage.

Fixes: 5a76aee24476 ("LU-8998 lfs: user space tools for PFL")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I1f0097aa002b29febcbf183cab02519b202540e5
Reviewed-on: https://review.whamcloud.com/35611
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs-find.1
lustre/tests/sanity-pfl.sh
lustre/utils/liblustreapi.c

index 92f879b..cfba95d 100644 (file)
@@ -245,7 +245,7 @@ are multiple OSTs that are being replaced.
 Stripe size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
 suffix is given.  For composite files, this matches the stripe
-size of any non-extension component.
+size of the last initialized non-extension component.
 .TP
 .BR --extension-size | --ext-size | -z
 Extension size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
index 9c71449..517bc1d 100644 (file)
@@ -674,7 +674,7 @@ test_15() {
        $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1"
        $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2"
        test_mkdir $parent/subdir
-       $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir ||
+       $LFS setstripe -E 6M -S 1M -c1 -E 30M -c4 -E eof -c -1 $parent/subdir ||
                error "setstripe to subdir"
        $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3"
        $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4"
@@ -724,6 +724,15 @@ test_15() {
        found=$($LFS find $ext_opts ! $cnt_opts $flg_opts $parent | wc -l)
        [ $found -eq 2 ] ||
                error "start-1M, end+5M, !count+2, flag=init, $found != 2"
+
+       # check last component stripe count
+       if [ $OSTCOUNT -gt 1 ]; then
+               touch $parent/subdir/f5
+               $TRUNCATE $parent/subdir/f5 $((32*1024*1024))
+               found=$($LFS find $parent/subdir -c $OSTCOUNT)
+               [[ "$found" == "$parent/subdir/f5" ]] ||
+                       error "got '$found' with stripe_count=$OSTCOUNT, not f5"
+       fi
 }
 run_test 15 "Verify component options for lfs find"
 
index c25456d..600e732 100644 (file)
@@ -4024,6 +4024,7 @@ static int find_check_stripe_size(struct find_param *param)
 {
        struct lov_comp_md_v1 *comp_v1 = NULL;
        struct lov_user_md_v1 *v1 = &param->fp_lmd->lmd_lmm;
+       __u32 stripe_size = 0;
        int ret, i, count = 1;
 
        if (v1->lmm_magic == LOV_USER_MAGIC_FOREIGN)
@@ -4044,17 +4045,17 @@ static int find_check_stripe_size(struct find_param *param)
                        ent = &comp_v1->lcm_entries[i];
                        if (ent->lcme_flags & LCME_FL_EXTENSION)
                                continue;
+                       if (!(ent->lcme_flags & LCME_FL_INIT))
+                               continue;
                }
-
-               ret = find_value_cmp(v1->lmm_stripe_size, param->fp_stripe_size,
-                                    param->fp_stripe_size_sign,
-                                    param->fp_exclude_stripe_size,
-                                    param->fp_stripe_size_units, 0);
-               /* If any stripe_size matches */
-               if (ret != -1)
-                       break;
+               stripe_size = v1->lmm_stripe_size;
        }
 
+       ret = find_value_cmp(stripe_size, param->fp_stripe_size,
+                            param->fp_stripe_size_sign,
+                            param->fp_exclude_stripe_size,
+                            param->fp_stripe_size_units, 0);
+
        return ret;
 }
 
@@ -4112,10 +4113,13 @@ static __u32 find_get_stripe_count(struct find_param *param)
                        v1 = lov_comp_entry(comp_v1, i);
 
                        ent = &comp_v1->lcm_entries[i];
+                       if (!(ent->lcme_flags & LCME_FL_INIT))
+                               continue;
+
                        if (ent->lcme_flags & LCME_FL_EXTENSION)
                                continue;
                }
-               stripe_count += v1->lmm_stripe_count;
+               stripe_count = v1->lmm_stripe_count;
        }
 
        return stripe_count;