Whamcloud - gitweb
LU-4870 lfsck: lock old MDT-object in migrating
[fs/lustre-release.git] / lustre / mdd / mdd_dir.c
index d6bb84b..6344e40 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -119,7 +119,8 @@ int mdd_lookup(const struct lu_env *env,
        if (rc != 0)
                RETURN(rc);
 
-       rc = __mdd_lookup(env, pobj, pattr, lname, fid, MAY_EXEC);
+       rc = __mdd_lookup(env, pobj, pattr, lname, fid,
+                         (spec != NULL && spec->sp_permitted) ? 0 : MAY_EXEC);
         RETURN(rc);
 }
 
@@ -1096,7 +1097,7 @@ int mdd_links_read(const struct lu_env *env, struct mdd_object *mdd_obj,
 struct lu_buf *mdd_links_get(const struct lu_env *env,
                             struct mdd_object *mdd_obj)
 {
-       struct linkea_data ldata = { 0 };
+       struct linkea_data ldata = { NULL };
        int rc;
 
        rc = mdd_links_read(env, mdd_obj, &ldata);
@@ -1842,19 +1843,9 @@ static int mdd_object_initialize(const struct lu_env *env,
                                 struct lu_attr *attr, struct thandle *handle,
                                 const struct md_op_spec *spec)
 {
-        int rc;
-        ENTRY;
-
-        /*
-         * Update attributes for child.
-         *
-         * FIXME:
-         *  (1) the valid bits should be converted between Lustre and Linux;
-         *  (2) maybe, the child attributes should be set in OSD when creation.
-         */
+       int rc = 0;
+       ENTRY;
 
-       rc = mdd_attr_set_internal(env, child, attr, handle, 0);
-       /* arguments are supposed to stay the same */
        if (S_ISDIR(attr->la_mode)) {
                 /* Add "." and ".." for newly created dir */
                 mdo_ref_add(env, child, handle);
@@ -2178,9 +2169,11 @@ static int mdd_object_create(const struct lu_env *env, struct mdd_object *pobj,
        /* During creation, there are only a few cases we need do xattr_set to
         * create stripes.
         * 1. regular file: see comments above.
-        * 2. create striped directory with provided stripeEA.
-        * 3. create striped directory because inherit default layout from the
-        * parent. */
+        * 2. dir: inherit default striping or pool settings from parent.
+        * 3. create striped directory with provided stripeEA.
+        * 4. create striped directory because inherit default layout from the
+        * parent.
+        */
        if (spec->no_create ||
            (S_ISREG(attr->la_mode) && spec->sp_cr_flags & MDS_OPEN_HAS_EA) ||
            S_ISDIR(attr->la_mode)) {
@@ -2344,7 +2337,7 @@ static int mdd_create(const struct lu_env *env, struct md_object *pobj,
        mdd_object_make_hint(env, mdd_pobj, son, attr, spec, hint);
 
        memset(ldata, 0, sizeof(*ldata));
-       if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_PARENT2)) {
+       if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_PARENT)) {
                struct lu_fid tfid = *mdd_object_fid(mdd_pobj);
 
                tfid.f_oid--;
@@ -2984,7 +2977,7 @@ static int mdd_linkea_update_child_internal(const struct lu_env *env,
                                            bool declare)
 {
        struct mdd_thread_info  *info = mdd_env_info(env);
-       struct linkea_data      ldata = {0};
+       struct linkea_data      ldata = { NULL };
        struct lu_buf           *buf = &info->mti_link_buf;
        int                     count;
        int                     rc = 0;
@@ -3360,8 +3353,8 @@ static int mdd_migrate_create(const struct lu_env *env,
        struct mdd_thread_info  *info = mdd_env_info(env);
        struct mdd_device       *mdd = mdo2mdd(&mdd_sobj->mod_obj);
        struct md_op_spec       *spec = &info->mti_spec;
-       struct lu_buf           lmm_buf = { 0 };
-       struct lu_buf           link_buf = { 0 };
+       struct lu_buf           lmm_buf = { NULL };
+       struct lu_buf           link_buf = { NULL };
        const struct lu_buf     *buf;
        struct thandle          *handle;
        struct lmv_mds_md_v1    *mgr_ea;
@@ -4092,6 +4085,8 @@ static int mdd_migrate(const struct lu_env *env, struct md_object *pobj,
                if (unlikely(OBD_FAIL_CHECK_RESET(OBD_FAIL_MIGRATE_NET_REP,
                                                  OBD_FAIL_MDS_REINT_NET_REP)))
                        GOTO(put, rc = 0);
+       } else {
+               OBD_FAIL_TIMEOUT(OBD_FAIL_MIGRATE_DELAY, cfs_fail_val);
        }
 
        /* step 4: update name entry to the new object */