Whamcloud - gitweb
LU-10308 misc: update Intel copyright messages for 2017
[fs/lustre-release.git] / lustre / mdd / mdd_orphans.c
index ee398cf..1f5f819 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,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, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -45,7 +41,6 @@
 
 #include <obd.h>
 #include <obd_class.h>
-#include <lustre_ver.h>
 #include <obd_support.h>
 #include <lustre_fid.h>
 #include "mdd_internal.h"
@@ -119,8 +114,7 @@ static inline int mdd_orphan_insert_obj(const struct lu_env *env,
        rec->rec_fid = lf;
        rec->rec_type = mdd_object_type(obj);
 
-       return dt_insert(env, dor, (const struct dt_rec *)rec, key, th,
-                        BYPASS_CAPA, 1);
+       return dt_insert(env, dor, (const struct dt_rec *)rec, key, th, 1);
 }
 
 static inline int mdd_orphan_delete_obj(const struct lu_env *env,
@@ -130,7 +124,7 @@ static inline int mdd_orphan_delete_obj(const struct lu_env *env,
 {
        struct dt_object *dor = mdd->mdd_orphans;
 
-       return dt_delete(env, dor, key, th, BYPASS_CAPA);
+       return dt_delete(env, dor, key, th);
 }
 
 static inline int mdd_orphan_ref_add(const struct lu_env *env,
@@ -227,12 +221,12 @@ static int orph_index_insert(const struct lu_env *env,
         if (!dt_try_as_dir(env, next))
                GOTO(out, rc = 0);
 
-       dt_delete(env, next, (const struct dt_key *)dotdot, th, BYPASS_CAPA);
+       dt_delete(env, next, (const struct dt_key *)dotdot, th);
 
        rec->rec_fid = lf_dor;
        rec->rec_type = S_IFDIR;
        dt_insert(env, next, (const struct dt_rec *)rec,
-                 (const struct dt_key *)dotdot, th, BYPASS_CAPA, 1);
+                 (const struct dt_key *)dotdot, th, 1);
 
 out:
         if (rc == 0)
@@ -318,14 +312,13 @@ static int orph_index_delete(const struct lu_env *env,
 }
 
 
-static int orphan_object_destroy(const struct lu_env *env,
-                                 struct mdd_object *obj,
-                                 struct dt_key *key)
+static int orphan_destroy(const struct lu_env *env, struct mdd_object *obj,
+                         struct dt_key *key)
 {
-        struct thandle *th = NULL;
-        struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
-        int rc = 0;
-        ENTRY;
+       struct thandle *th = NULL;
+       struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
+       int rc = 0;
+       ENTRY;
 
        th = mdd_trans_create(env, mdd);
        if (IS_ERR(th)) {
@@ -333,22 +326,22 @@ static int orphan_object_destroy(const struct lu_env *env,
                RETURN(PTR_ERR(th));
        }
 
-        rc = orph_declare_index_delete(env, obj, th);
-        if (rc)
-                GOTO(stop, rc);
+       rc = orph_declare_index_delete(env, obj, th);
+       if (rc)
+               GOTO(stop, rc);
 
        rc = mdo_declare_destroy(env, obj, th);
-        if (rc)
-                GOTO(stop, rc);
+       if (rc)
+               GOTO(stop, rc);
 
-        rc = mdd_trans_start(env, mdd, th);
-        if (rc)
-                GOTO(stop, rc);
+       rc = mdd_trans_start(env, mdd, th);
+       if (rc)
+               GOTO(stop, rc);
 
-        mdd_write_lock(env, obj, MOR_TGT_CHILD);
-        if (likely(obj->mod_count == 0)) {
-                mdd_orphan_write_lock(env, mdd);
-                rc = mdd_orphan_delete_obj(env, mdd, key, th);
+       mdd_write_lock(env, obj, MOR_TGT_CHILD);
+       if (likely(obj->mod_count == 0)) {
+               mdd_orphan_write_lock(env, mdd);
+               rc = mdd_orphan_delete_obj(env, mdd, key, th);
                if (rc == 0) {
                        mdo_ref_del(env, obj, th);
                        if (S_ISDIR(mdd_object_type(obj))) {
@@ -357,15 +350,15 @@ static int orphan_object_destroy(const struct lu_env *env,
                        }
                        rc = mdo_destroy(env, obj, th);
                } else
-                        CERROR("could not delete object: rc = %d\n",rc);
-                mdd_orphan_write_unlock(env, mdd);
-        }
-        mdd_write_unlock(env, obj);
+                       CERROR("could not delete object: rc = %d\n", rc);
+               mdd_orphan_write_unlock(env, mdd);
+       }
+       mdd_write_unlock(env, obj);
 
 stop:
-        mdd_trans_stop(env, mdd, 0, th);
+       rc = mdd_trans_stop(env, mdd, 0, th);
 
-        RETURN(rc);
+       RETURN(rc);
 }
 
 /**
@@ -379,25 +372,24 @@ stop:
  * \retval -ve error
  */
 static int orph_key_test_and_del(const struct lu_env *env,
-                                 struct mdd_device *mdd,
-                                 struct lu_fid *lf,
-                                 struct dt_key *key)
+                                struct mdd_device *mdd, struct lu_fid *lf,
+                                struct dt_key *key)
 {
-        struct mdd_object *mdo;
-        int rc;
+       struct mdd_object *mdo;
+       int rc;
 
-        mdo = mdd_object_find(env, mdd, lf);
+       mdo = mdd_object_find(env, mdd, lf);
 
-        if (IS_ERR(mdo))
-                return PTR_ERR(mdo);
+       if (IS_ERR(mdo))
+               return PTR_ERR(mdo);
 
-        rc = -EBUSY;
-        if (mdo->mod_count == 0) {
-                CDEBUG(D_HA, "Found orphan "DFID", delete it\n", PFID(lf));
-                rc = orphan_object_destroy(env, mdo, key);
-                if (rc) /* so replay-single.sh test_37 works */
-                        CERROR("%s: error unlinking orphan "DFID" from "
-                               "PENDING: rc = %d\n",
+       rc = -EBUSY;
+       if (mdo->mod_count == 0) {
+               CDEBUG(D_HA, "Found orphan "DFID", delete it\n", PFID(lf));
+               rc = orphan_destroy(env, mdo, key);
+               if (rc) /* so replay-single.sh test_37 works */
+                       CERROR("%s: error unlinking orphan "DFID" from "
+                              "PENDING: rc = %d\n",
                               mdd2obd_dev(mdd)->obd_name, PFID(lf), rc);
         } else {
                 mdd_write_lock(env, mdo, MOR_TGT_CHILD);
@@ -440,7 +432,7 @@ static int orph_index_iterate(const struct lu_env *env,
         ENTRY;
 
         iops = &dor->do_index_ops->dio_it;
-        it = iops->init(env, dor, LUDA_64BITHASH, BYPASS_CAPA);
+       it = iops->init(env, dor, LUDA_64BITHASH);
         if (IS_ERR(it)) {
                 rc = PTR_ERR(it);
                 CERROR("%s: cannot clean PENDING: rc = %d\n",
@@ -544,7 +536,7 @@ int orph_index_init(const struct lu_env *env, struct mdd_device *mdd)
        if (!dt_try_as_dir(env, d)) {
                CERROR("%s: \"%s\" is not an index: rc = %d\n",
                       mdd2obd_dev(mdd)->obd_name, orph_index_name, rc);
-               lu_object_put(env, &d->do_lu);
+               dt_object_put(env, d);
                RETURN(-ENOTDIR);
        }
        mdd->mdd_orphans = d;
@@ -553,12 +545,12 @@ int orph_index_init(const struct lu_env *env, struct mdd_device *mdd)
 
 void orph_index_fini(const struct lu_env *env, struct mdd_device *mdd)
 {
-        ENTRY;
-        if (mdd->mdd_orphans != NULL) {
-                lu_object_put(env, &mdd->mdd_orphans->do_lu);
-                mdd->mdd_orphans = NULL;
-        }
-        EXIT;
+       ENTRY;
+       if (mdd->mdd_orphans != NULL) {
+               dt_object_put(env, mdd->mdd_orphans);
+               mdd->mdd_orphans = NULL;
+       }
+       EXIT;
 }
 
 static int __mdd_orphan_cleanup(void *args)