Whamcloud - gitweb
LU-13424 mdt: fix DOM entry check 57/38257/3
authorMikhail Pershin <mpershin@whamcloud.com>
Thu, 16 Apr 2020 06:22:17 +0000 (09:22 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Apr 2020 16:48:40 +0000 (16:48 +0000)
The mdt_lmm_dom_entry() tries to determine if layout has
DOM entry or not but does that correctly only if DOM entry
is the first one in layout and file is not mirrored.
Otherwise it scans through all entries and wronly reports
that DOM entry exists.

Patch does the following:
- correct initialization of 'has_dom=false' by default
- correct check for DOM+OST case, only if both entries were
  found among initiated entries
- add test case for directory migration with mirrored file

Signed-off-by: Mikhail Pershin <mpershin@whamcloud.com>
Change-Id: I43c33528213132f03ebec2debec48b8d53ee229f
Reviewed-on: https://review.whamcloud.com/38257
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_internal.h
lustre/tests/sanity.sh

index 6e46e8f..4b4afef 100644 (file)
@@ -670,7 +670,7 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm)
        struct lov_comp_md_v1 *comp_v1;
        struct lov_mds_md *v1;
        __u32 off;
-       bool has_dom = true;
+       bool has_dom = false, has_ost = false;
        int i;
 
        if (le32_to_cpu(lmm->lmm_magic) != LOV_MAGIC_COMP_V1)
@@ -686,21 +686,22 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm)
                return LMM_NO_DOM;
 
        for (i = 0; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
-               int j;
+               struct lov_comp_md_entry_v1 *lcme;
 
-               off = le32_to_cpu(comp_v1->lcm_entries[i].lcme_offset);
+               lcme = &comp_v1->lcm_entries[i];
+               if (!(le32_to_cpu(lcme->lcme_flags) & LCME_FL_INIT))
+                       continue;
+
+               off = le32_to_cpu(lcme->lcme_offset);
                v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
 
                if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) ==
                    LOV_PATTERN_MDT)
                        has_dom = true;
-
-               for (j = 0; j < le16_to_cpu(v1->lmm_stripe_count); j++) {
-                       /* if there is any object on OST */
-                       if (le32_to_cpu(v1->lmm_objects[j].l_ost_idx) !=
-                           (__u32)-1UL)
-                               return LMM_DOM_OST;
-               }
+               else
+                       has_ost = true;
+               if (has_dom && has_ost)
+                       return LMM_DOM_OST;
        }
        return has_dom ? LMM_DOM_ONLY : LMM_NO_DOM;
 }
index 1ff6090..991c6d6 100755 (executable)
@@ -17369,6 +17369,21 @@ test_230m() {
 }
 run_test 230m "xattrs not changed after dir migration"
 
+test_230n() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
+               skip "Need MDS version at least 2.13.53"
+
+       $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
+       cat /etc/hosts > $DIR/$tdir/$tfile
+       $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
+       $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
+
+       cmp /etc/hosts $DIR/$tdir/$tfile ||
+               error "File data mismatch after migration"
+}
+run_test 230n "Dir migration with mirrored file"
+
 test_231a()
 {
        # For simplicity this test assumes that max_pages_per_rpc