Whamcloud - gitweb
LU-1678 mdd: don't create LOV EA by going thru .lustre path
authorBobi Jam <bobijam@whamcloud.com>
Thu, 26 Jul 2012 11:04:48 +0000 (13:04 +0200)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Sep 2012 14:34:34 +0000 (10:34 -0400)
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 <jacques-charles.lafoucriere@cea.fr>
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: Ib223da44d16bf3a541269d5cfb60826e43345493
Reviewed-on: http://review.whamcloud.com/3483
Tested-by: Hudson
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/tests/sanity.sh

index e1a3169..fb1cd9a 100644 (file)
@@ -53,6 +53,7 @@
 #endif
 #include <lustre_fsfilt.h>
 #include <lustre/lustre_lfsck_user.h>
+#include <lustre_fid.h>
 
 #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);
index 681543c..df20c2a 100644 (file)
@@ -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);
index ca146f6..6bf9e08 100644 (file)
@@ -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"