Whamcloud - gitweb
LU-7434 ptlrpc: lost bulk leads to a hang
[fs/lustre-release.git] / lustre / mdd / mdd_orphans.c
index 8ab42ca..e7ce0fd 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/
@@ -93,36 +93,33 @@ static struct dt_key* orph_key_fill_18(const struct lu_env *env,
 }
 
 static inline void mdd_orphan_write_lock(const struct lu_env *env,
-                                    struct mdd_device *mdd)
+                                        struct mdd_device *mdd)
 {
-
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        dor->do_ops->do_write_lock(env, dor, MOR_TGT_ORPHAN);
+       struct dt_object *dor = mdd->mdd_orphans;
+       dt_write_lock(env, dor, MOR_TGT_ORPHAN);
 }
 
 static inline void mdd_orphan_write_unlock(const struct lu_env *env,
-                                           struct mdd_device *mdd)
+                                          struct mdd_device *mdd)
 {
-
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        dor->do_ops->do_write_unlock(env, dor);
+       struct dt_object *dor = mdd->mdd_orphans;
+       dt_write_unlock(env, dor);
 }
 
 static inline int mdd_orphan_insert_obj(const struct lu_env *env,
-                                        struct mdd_device *mdd,
-                                        struct mdd_object *obj,
-                                        __u32 op,
-                                        struct thandle *th)
+                                       struct mdd_device *mdd,
+                                       struct mdd_object *obj,
+                                       __u32 op, struct thandle *th)
 {
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        const struct lu_fid     *lf     = mdo2fid(obj);
-        struct dt_key           *key    = orph_key_fill(env, lf, op);
-        ENTRY;
+       struct dt_insert_rec    *rec    = &mdd_env_info(env)->mti_dt_rec;
+       struct dt_object        *dor    = mdd->mdd_orphans;
+       const struct lu_fid     *lf     = mdo2fid(obj);
+       struct dt_key           *key    = orph_key_fill(env, lf, op);
+
+       rec->rec_fid = lf;
+       rec->rec_type = mdd_object_type(obj);
 
-        return  dor->do_index_ops->dio_insert(env, dor,
-                                              (struct dt_rec *)lf,
-                                              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,27 +127,25 @@ static inline int mdd_orphan_delete_obj(const struct lu_env *env,
                                         struct dt_key *key,
                                         struct thandle *th)
 {
-        struct dt_object        *dor    = mdd->mdd_orphans;
+       struct dt_object *dor = mdd->mdd_orphans;
 
-        return  dor->do_index_ops->dio_delete(env, dor,
-                                              key, th,
-                                              BYPASS_CAPA);
+       return dt_delete(env, dor, key, th);
 }
 
-static inline void mdd_orphan_ref_add(const struct lu_env *env,
-                                 struct mdd_device *mdd,
-                                 struct thandle *th)
+static inline int mdd_orphan_ref_add(const struct lu_env *env,
+                                    struct mdd_device *mdd,
+                                    struct thandle *th)
 {
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        dor->do_ops->do_ref_add(env, dor, th);
+       struct dt_object *dor = mdd->mdd_orphans;
+       return dt_ref_add(env, dor, th);
 }
 
-static inline void mdd_orphan_ref_del(const struct lu_env *env,
-                                 struct mdd_device *mdd,
-                                 struct thandle *th)
+static inline int mdd_orphan_ref_del(const struct lu_env *env,
+                                    struct mdd_device *mdd,
+                                    struct thandle *th)
 {
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        dor->do_ops->do_ref_del(env, dor, th);
+       struct dt_object *dor = mdd->mdd_orphans;
+       return dt_ref_del(env, dor, th);
 }
 
 
@@ -158,14 +153,18 @@ int orph_declare_index_insert(const struct lu_env *env,
                              struct mdd_object *obj,
                              umode_t mode, struct thandle *th)
 {
+       struct dt_insert_rec    *rec = &mdd_env_info(env)->mti_dt_rec;
        struct mdd_device       *mdd = mdo2mdd(&obj->mod_obj);
        struct dt_key           *key;
        int                     rc;
 
        key = orph_key_fill(env, mdo2fid(obj), ORPH_OP_UNLINK);
 
-       rc = dt_declare_insert(env, mdd->mdd_orphans, NULL, key, th);
-       if (rc)
+       rec->rec_fid = mdo2fid(obj);
+       rec->rec_type = mode;
+       rc = dt_declare_insert(env, mdd->mdd_orphans,
+                              (const struct dt_rec *)rec, key, th);
+       if (rc != 0)
                return rc;
 
        rc = mdo_declare_ref_add(env, obj, th);
@@ -187,21 +186,23 @@ int orph_declare_index_insert(const struct lu_env *env,
        if (rc)
                return rc;
 
-       rc = mdo_declare_index_insert(env, obj, NULL, dotdot, th);
+       rc = mdo_declare_index_insert(env, obj,
+                                     lu_object_fid(&mdd->mdd_orphans->do_lu),
+                                     S_IFDIR, dotdot, th);
 
        return rc;
 }
 
 static int orph_index_insert(const struct lu_env *env,
-                             struct mdd_object *obj,
-                             __u32 op,
-                             struct thandle *th)
+                            struct mdd_object *obj,
+                            __u32 op, struct thandle *th)
 {
-        struct mdd_device       *mdd    = mdo2mdd(&obj->mod_obj);
-        struct dt_object        *dor    = mdd->mdd_orphans;
-        const struct lu_fid     *lf_dor = lu_object_fid(&dor->do_lu);
-        struct dt_object        *next   = mdd_object_child(obj);
-        int rc;
+       struct mdd_device       *mdd    = mdo2mdd(&obj->mod_obj);
+       struct dt_object        *dor    = mdd->mdd_orphans;
+       const struct lu_fid     *lf_dor = lu_object_fid(&dor->do_lu);
+       struct dt_object        *next   = mdd_object_child(obj);
+       struct dt_insert_rec    *rec    = &mdd_env_info(env)->mti_dt_rec;
+       int                      rc;
         ENTRY;
 
         LASSERT(mdd_write_locked(env, obj) != 0);
@@ -224,14 +225,13 @@ static int orph_index_insert(const struct lu_env *env,
          * from here */
         if (!dt_try_as_dir(env, next))
                GOTO(out, rc = 0);
-        next->do_index_ops->dio_delete(env, next,
-                                       (const struct dt_key *)dotdot,
-                                       th, BYPASS_CAPA);
 
-        next->do_index_ops->dio_insert(env, next,
-                                       (struct dt_rec *)lf_dor,
-                                       (const struct dt_key *)dotdot,
-                                       th, BYPASS_CAPA, 1);
+       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, 1);
 
 out:
         if (rc == 0)
@@ -439,7 +439,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",