From: Bobi Jam Date: Thu, 26 Jul 2012 11:04:48 +0000 (+0200) Subject: LU-1678 mdd: don't create LOV EA by going thru .lustre path X-Git-Tag: 2.3.51~137 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3b7d840a6f1ca207ec810272013bc7aa3907f96b LU-1678 mdd: don't create LOV EA by going thru .lustre path When a file is created with O_LOV_DELAY_CREAT, we should not create its LOV EA data by going through .lustre path. Add a test to sanity.sh open by fid test suite (test_154). Signed-off-by: jc lafoucriere Signed-off-by: Bobi Jam Change-Id: Ib223da44d16bf3a541269d5cfb60826e43345493 Reviewed-on: http://review.whamcloud.com/3483 Tested-by: Hudson Reviewed-by: Lai Siyao Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index e1a3169..fb1cd9a 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -53,6 +53,7 @@ #endif #include #include +#include #ifdef HAVE_QUOTA_SUPPORT /* quota stuff */ @@ -585,6 +586,11 @@ static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj) return lu_object_fid(&obj->mod_obj.mo_lu); } +static inline int mdd_object_obf(const struct mdd_object *obj) +{ + return lu_fid_eq(mdo2fid(obj), &LU_OBF_FID); +} + static inline cfs_umode_t mdd_object_type(const struct mdd_object *obj) { return lu_object_attr(&obj->mod_obj.mo_lu); diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 681543c..df20c2a 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -463,6 +463,13 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd, LASSERT(parent != NULL); + /* + * can not create child's lov_mds_md by access it + * thru .lustre path + */ + if (mdd_object_obf(parent)) + GOTO(out_oti, rc = -EBADFD); + _lmm = mdd_max_lmm_get(env, mdd); if (_lmm == NULL) GOTO(out_oti, rc = -ENOMEM); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ca146f6..6bf9e08 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7893,6 +7893,17 @@ test_154() { mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre && error "rename .lustre to itself should fail." + $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2 + fid=$($LFS path2fid $DIR/$tfile-2) + echo "cp /etc/passwd $DIR/.lustre/fid/$fid" + cp /etc/passwd $DIR/.lustre/fid/$fid && + error "create lov data thru .lustre should fail." + echo "cp /etc/passwd $DIR/$tfile-2" + cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed." + echo "diff /etc/passwd $DIR/.lustre/fid/$fid" + diff /etc/passwd $DIR/.lustre/fid/$fid || + error "diff /etc/passwd $DIR/.lustre/fid/$fid failed." + echo "Open-by-FID succeeded" } run_test 154 "Open-by-FID"