Whamcloud - gitweb
LU-15070 llite: update default LMV upon any change 37/45237/4
authorLai Siyao <lai.siyao@whamcloud.com>
Tue, 12 Oct 2021 22:15:37 +0000 (18:15 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Nov 2021 02:42:21 +0000 (02:42 +0000)
max_inherit and max_inherit_rr was newly added, and they are missing
in lsm_md_eq(), therefore client may not update default LMV when
either of these two fields is changed.

Add sanityn 112.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Iac71b530b3702105c4213715826b1782c6aba7ca
Reviewed-on: https://review.whamcloud.com/45237
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_lmv.h
lustre/llite/llite_lib.c
lustre/tests/sanityn.sh

index abb89a3..2ffd77f 100644 (file)
@@ -93,6 +93,8 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
            lsm1->lsm_md_master_mdt_index !=
                                lsm2->lsm_md_master_mdt_index ||
            lsm1->lsm_md_hash_type != lsm2->lsm_md_hash_type ||
+           lsm1->lsm_md_max_inherit != lsm2->lsm_md_max_inherit ||
+           lsm1->lsm_md_max_inherit_rr != lsm2->lsm_md_max_inherit_rr ||
            lsm1->lsm_md_layout_version !=
                                lsm2->lsm_md_layout_version ||
            lsm1->lsm_md_migrate_offset !=
@@ -109,6 +111,12 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
                                       &lsm2->lsm_md_oinfo[idx].lmo_fid))
                                return false;
                }
+       } else if (lsm1->lsm_md_magic == LMV_USER_MAGIC_SPECIFIC) {
+               for (idx = 0; idx < lsm1->lsm_md_stripe_count; idx++) {
+                       if (lsm1->lsm_md_oinfo[idx].lmo_mds !=
+                           lsm2->lsm_md_oinfo[idx].lmo_mds)
+                               return false;
+               }
        }
 
        return true;
@@ -123,13 +131,13 @@ static inline void lsm_md_dump(int mask, const struct lmv_stripe_md *lsm)
         * terminated string so only print LOV_MAXPOOLNAME bytes.
         */
        CDEBUG(mask,
-              "magic %#x stripe count %d master mdt %d hash type %s:%#x max inherit %hhu version %d migrate offset %d migrate hash %#x pool %.*s\n",
+              "magic %#x stripe count %d master mdt %d hash type %s:%#x max-inherit %hhu max-inherit-rr %hhu version %d migrate offset %d migrate hash %#x pool %.*s\n",
               lsm->lsm_md_magic, lsm->lsm_md_stripe_count,
               lsm->lsm_md_master_mdt_index,
               valid_hash ? "invalid hash" :
                            mdt_hash_name[lsm->lsm_md_hash_type & (LMV_HASH_TYPE_MAX - 1)],
               lsm->lsm_md_hash_type, lsm->lsm_md_max_inherit,
-              lsm->lsm_md_layout_version,
+              lsm->lsm_md_max_inherit_rr, lsm->lsm_md_layout_version,
               lsm->lsm_md_migrate_offset, lsm->lsm_md_migrate_hash,
               LOV_MAXPOOLNAME, lsm->lsm_md_pool_name);
 
index 67eecc2..87ccf1b 100644 (file)
@@ -1599,6 +1599,8 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
 
+       ENTRY;
+
        if (!md->default_lmv) {
                /* clear default lsm */
                if (lli->lli_default_lsm_md) {
@@ -1609,7 +1611,7 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md)
                        }
                        up_write(&lli->lli_lsm_sem);
                }
-               return;
+               RETURN_EXIT;
        }
 
        if (lli->lli_default_lsm_md) {
@@ -1618,7 +1620,7 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md)
                if (lli->lli_default_lsm_md &&
                    lsm_md_eq(lli->lli_default_lsm_md, md->default_lmv)) {
                        up_read(&lli->lli_lsm_sem);
-                       return;
+                       RETURN_EXIT;
                }
                up_read(&lli->lli_lsm_sem);
        }
@@ -1630,6 +1632,7 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md)
        lsm_md_dump(D_INODE, md->default_lmv);
        md->default_lmv = NULL;
        up_write(&lli->lli_lsm_sem);
+       RETURN_EXIT;
 }
 
 static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
index 91f9f9a..7f20a86 100755 (executable)
@@ -5714,6 +5714,37 @@ test_111() {
 }
 run_test 111 "A racy rename/link an open file should not cause fs corruption"
 
+test_112() {
+       (( MDSCOUNT >= 2 )) ||
+               skip "We need at least 2 MDTs for this test"
+
+       (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
+               skip "Need server version at least 2.14.54"
+
+       local rr
+       local count
+
+       rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
+       rr=${rr%%%}
+       stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
+
+       mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
+       $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
+       $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
+               error "setdirstripe s3 failed"
+       $LCTL set_param lmv.*.qos_threshold_rr=90
+       mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
+       count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
+       (( count == 64 )) || error "only $count subdirs created on MDT0"
+
+       $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
+               error "setdirstripe s3 failed"
+       mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
+       count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
+       (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
+}
+run_test 112 "update max-inherit in default LMV"
+
 log "cleanup: ======================================================"
 
 # kill and wait in each test only guarentee script finish, but command in script