From ebfc6f4b54961e5e0762af7d2555f2dc5d1e1ec3 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Wed, 5 Mar 2014 20:56:38 -0500 Subject: [PATCH] LU-4719 mdt: Don't try to print non-existent objects 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 Reviewed-on: http://review.whamcloud.com/9520 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Matt Ezell Reviewed-by: James Simmons Tested-by: Maloo --- lustre/mdt/mdt_handler.c | 2 +- lustre/mdt/mdt_internal.h | 2 +- lustre/mdt/mdt_lib.c | 30 ++++++++++++++++++++---------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 669d778..0e1f0f6 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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)); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 0eaa88f..7970b86 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -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 *); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index e7e3406..f0427e4 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -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), -- 1.8.3.1