+static inline
+int mdo_declare_index_insert(const struct lu_env *env, struct mdd_object *obj,
+ const struct lu_fid *fid, const char *name,
+ struct thandle *handle)
+{
+ struct dt_object *next = mdd_object_child(obj);
+ int rc = 0;
+
+ /*
+ * if the object doesn't exist yet, then it's supposed to be created
+ * and declaration of the creation should be enough to insert ./..
+ */
+ if (mdd_object_exists(obj)) {
+ rc = -ENOTDIR;
+ if (dt_try_as_dir(env, next))
+ rc = dt_declare_insert(env, next,
+ (struct dt_rec *)fid,
+ (const struct dt_key *)name,
+ handle);
+ }
+
+ return rc;
+}
+
+static inline
+int mdo_declare_index_delete(const struct lu_env *env, struct mdd_object *obj,
+ const char *name, struct thandle *handle)
+{
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!dt_try_as_dir(env, next))
+ return -ENOTDIR;
+
+ return dt_declare_delete(env, next, (const struct dt_key *)name,
+ handle);
+}
+
+static inline int mdo_declare_ref_add(const struct lu_env *env,
+ struct mdd_object *obj,
+ struct thandle *handle)
+{
+ struct dt_object *next = mdd_object_child(obj);
+ return dt_declare_ref_add(env, next, handle);
+}
+
+static inline int mdo_ref_add(const struct lu_env *env, struct mdd_object *obj,
+ struct thandle *handle)