Whamcloud - gitweb
LU-4719 mdt: Don't try to print non-existent objects 20/9520/3
authorOleg Drokin <oleg.drokin@intel.com>
Thu, 6 Mar 2014 01:56:38 +0000 (20:56 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 20 Mar 2014 12:48:14 +0000 (12:48 +0000)
mdt_dump_lmm() needs to make sure it's not trying to print
objects for a default striping from a directory, since there
are not objects in this case.

Return early if the D_INFO debug mask is disenabled, so it
doesn't iterate through the LOV/LMV layout at all.  That is
just a waste of effort.

Change-Id: I2fffdaefad2a6b05247676441451fffdca620dcd
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/9520
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: Matt Ezell <ezellma@ornl.gov>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lib.c

index 669d778..0e1f0f6 100644 (file)
@@ -860,12 +860,12 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
         if (mdt_body_has_lov(la, reqbody)) {
                 if (ma->ma_valid & MA_LOV) {
                         LASSERT(ma->ma_lmm_size);
-                        mdt_dump_lmm(D_INFO, ma->ma_lmm);
                         repbody->eadatasize = ma->ma_lmm_size;
                         if (S_ISDIR(la->la_mode))
                                 repbody->valid |= OBD_MD_FLDIREA;
                         else
                                 repbody->valid |= OBD_MD_FLEASIZE;
+                        mdt_dump_lmm(D_INFO, ma->ma_lmm, repbody->valid);
                 }
                if (ma->ma_valid & MA_LMV) {
                        LASSERT(S_ISDIR(la->la_mode));
index 0eaa88f..7970b86 100644 (file)
@@ -769,7 +769,7 @@ struct lu_buf *mdt_buf(const struct lu_env *env, void *area, ssize_t len);
 const struct lu_buf *mdt_buf_const(const struct lu_env *env,
                                    const void *area, ssize_t len);
 
-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);
 void mdt_dump_lmv(unsigned int level, const union lmv_mds_md *lmv);
 
 int mdt_check_ucred(struct mdt_thread_info *);
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),