From: John L. Hammond Date: Tue, 22 Jul 2014 21:30:08 +0000 (-0500) Subject: LU-5044 mdd: do not return .lustre from readdir X-Git-Tag: 2.6.51~73 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F11186%2F2;p=fs%2Flustre-release.git LU-5044 mdd: do not return .lustre from readdir In mdd_dir_page_build() skip dirents with the FID of .lustre preventing that directory from being return by readdir on Lustre clients. Add a sanity tets to this effect. Signed-off-by: John L. Hammond Change-Id: Ieecb77a286748c4bf4df4dee68d7f33670a0c286 Reviewed-on: http://review.whamcloud.com/11186 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: wangdi Tested-by: Maloo --- diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 9f0f8c2..a6f9297 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -1849,6 +1849,7 @@ static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp, __u64 hash = 0; struct lu_dirent *ent; struct lu_dirent *last = NULL; + struct lu_fid fid; int first = 1; memset(area, 0, sizeof (*dp)); @@ -1885,6 +1886,12 @@ static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp, /* osd might not able to pack all attributes, * so recheck rec length */ recsize = le16_to_cpu(ent->lde_reclen); + + if (le32_to_cpu(ent->lde_attrs) & LUDA_FID) { + fid_le_to_cpu(&fid, &ent->lde_fid); + if (fid_is_dot_lustre(&fid)) + goto next; + } } else { result = (last != NULL) ? 0 :-EINVAL; goto out; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 0f7c7d4..cb99d07 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9670,6 +9670,17 @@ test_154d() { } run_test 154d "Verify open file fid" +test_154e() +{ + [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] && + skip "Need MDS version at least 2.6.50" && return + + if ls -a $MOUNT | grep -q '^\.lustre$'; then + error ".lustre returned by readdir" + fi +} +run_test 154e ".lustre is not returned by readdir" + test_155_small_load() { local temp=$TMP/$tfile local file=$DIR/$tfile