Whamcloud - gitweb
LU-13748 mdt: remove LASSERT in mdt_dump_lmm() 32/50532/10
authorAndreas Dilger <adilger@whamcloud.com>
Tue, 4 Apr 2023 01:42:31 +0000 (19:42 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 May 2023 07:07:09 +0000 (07:07 +0000)
Change LASSERT() in mdt_dump_lmm() into a CERROR(), since this
function is normally used for debugging and it doesn't help to
crash the MDS just when it complaining about some file layout.

Add sanity test_27Cg that triggered this initially.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I27f0b4489de48d6f197e0143589d76428d85e549
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50532
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_lib.c
lustre/tests/sanity.sh

index bc64ce7..9ec750d 100644 (file)
@@ -660,17 +660,18 @@ void mdt_dump_lmm(int level, const struct lov_mds_md *lmm, __u64 valid)
        if (likely(!cfs_cdebug_show(level, DEBUG_SUBSYSTEM)))
                return;
 
-       CDEBUG(level, "objid "DOSTID", magic 0x%08X, pattern %#X\n",
-              POSTID(&lmm->lmm_oi), lmm_magic,
-              le32_to_cpu(lmm->lmm_pattern));
+       CDEBUG_LIMIT(level, "objid="DOSTID" magic=0x%08X pattern=%#X\n",
+                    POSTID(&lmm->lmm_oi), lmm_magic,
+                    le32_to_cpu(lmm->lmm_pattern));
 
-       /* No support for compount layouts yet */
+       /* No support for compound layouts yet */
        if (lmm_magic != LOV_MAGIC_V1 && lmm_magic != LOV_MAGIC_V3)
                return;
 
        count = le16_to_cpu(((struct lov_user_md *)lmm)->lmm_stripe_count);
-       CDEBUG(level, "stripe_size=0x%x, stripe_count=0x%x\n",
-              le32_to_cpu(lmm->lmm_stripe_size), count);
+       CDEBUG_LIMIT(level, "stripe_size=0x%x, %sstripe_count=0x%x\n",
+                    le32_to_cpu(lmm->lmm_stripe_size),
+                    count > LOV_MAX_STRIPE_COUNT ? "bad " : "", count);
 
        /* If it's a directory or a released file, then there are
         * no actual objects to print, so bail out. */
@@ -678,13 +679,15 @@ void mdt_dump_lmm(int level, const struct lov_mds_md *lmm, __u64 valid)
            le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED)
                return;
 
-       LASSERT(count <= LOV_MAX_STRIPE_COUNT);
+       if (unlikely(count > LOV_MAX_STRIPE_COUNT))
+               return;
+
        for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++) {
                struct ost_id oi;
 
                ostid_le_to_cpu(&lod->l_ost_oi, &oi);
-               CDEBUG(level, "stripe %u idx %u subobj "DOSTID"\n",
-                      i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi));
+               CDEBUG_LIMIT(level, "stripe %u idx %u subobj "DOSTID"\n",
+                            i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi));
        }
 }
 
index 6bde419..dbd9888 100755 (executable)
@@ -2602,6 +2602,31 @@ test_27Cg() {
 }
 run_test 27Cg "test setstripe with wrong OST idx"
 
+test_27Ch() {
+       [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
+               skip "server does not support overstriping"
+       (( $MDS1_VERSION >= $(version_code 2.15.55.102) )) ||
+               skip "need MDS >= 2.12.55.102 for mdt_dump_lmm fix"
+
+       stack_trap "rm -f $DIR/$tfile"
+       # start_full_debug_logging
+       $LFS setstripe -S 64K -C -1 $DIR/$tfile || error "create $tfile failed"
+       $LFS getstripe -c $DIR/$tfile || error "getstripe $tfile failed"
+       cancel_lru_locks
+       $LFS getstripe -c $DIR/$tfile || error "getstripe failed after clear"
+
+       test_mkdir $DIR/$tdir
+       stack_trap "rm -rf $DIR/$tdir/$tfile"
+       $LFS setstripe -S 64K -C -1 $DIR/$tdir || error "mkdir $tdir failed"
+       $LFS getstripe -y $DIR/$tdir || error "getstripe $tdir failed"
+       touch $DIR/$tdir/$tfile || error "create $tdir/$tfile failed"
+       cancel_lru_locks
+       $LFS getstripe -c $DIR/$tdir/$tfile ||
+               error "getstripe $tdir/$tfile failed"
+       #stop_full_debug_logging
+}
+run_test 27Ch "overstriping with -C -1 in mdt_dump_lmm"
+
 test_27D() {
        [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
        [ -n "$FILESET" ] && skip "SKIP due to FILESET set"