Whamcloud - gitweb
LU-4719 mdt: Don't try to print non-existent objects
[fs/lustre-release.git] / lustre / mdt / mdt_lib.c
index e7e3406..f0427e4 100644 (file)
@@ -529,26 +529,33 @@ int mdt_init_ucred_reint(struct mdt_thread_info *info)
 }
 
 /* copied from lov/lov_ea.c, just for debugging, will be removed later */
-void mdt_dump_lmm(int level, const struct lov_mds_md *lmm)
+void mdt_dump_lmm(int level, const struct lov_mds_md *lmm, __u64 valid)
 {
-        const struct lov_ost_data_v1 *lod;
-        int                           i;
-        __u16                         count;
+       const struct lov_ost_data_v1    *lod;
+       int                              i;
+       __u16                            count;
 
-        count = le16_to_cpu(((struct lov_user_md*)lmm)->lmm_stripe_count);
+       if (likely(!cfs_cdebug_show(level, DEBUG_SUBSYSTEM)))
+               return;
+
+       count = le16_to_cpu(((struct lov_user_md *)lmm)->lmm_stripe_count);
 
        CDEBUG(level, "objid "DOSTID", magic 0x%08X, pattern %#X\n",
               POSTID(&lmm->lmm_oi), le32_to_cpu(lmm->lmm_magic),
               le32_to_cpu(lmm->lmm_pattern));
-        CDEBUG(level,"stripe_size=0x%x, stripe_count=0x%x\n",
-               le32_to_cpu(lmm->lmm_stripe_size), count);
-        if (count == LOV_ALL_STRIPES ||
+       CDEBUG(level, "stripe_size=0x%x, stripe_count=0x%x\n",
+              le32_to_cpu(lmm->lmm_stripe_size), count);
+
+       /* If it's a directory or a released file, then there are
+        * no actual objects to print, so bail out. */
+       if (valid & OBD_MD_FLDIREA ||
            le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED)
-                return;
+               return;
 
        LASSERT(count <= LOV_MAX_STRIPE_COUNT);
        for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++) {
-               struct ost_id   oi;
+               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));
@@ -560,6 +567,9 @@ void mdt_dump_lmv(unsigned int level, const union lmv_mds_md *lmv)
        const struct lmv_mds_md_v1 *lmm1;
        int                        i;
 
+       if (likely(!cfs_cdebug_show(level, DEBUG_SUBSYSTEM)))
+               return;
+
        lmm1 = &lmv->lmv_md_v1;
        CDEBUG(level, "magic 0x%08X, master %#X stripe_count %#x\n",
               le32_to_cpu(lmm1->lmv_magic),