+ struct orph_key *key = &mdd_ctx_info(ctx)->mti_orph_key;
+ LASSERT(key);
+ key->ok_fid.f_seq = 0;
+ key->ok_fid.f_oid = 0;
+ key->ok_fid.f_ver = 0;
+ key->ok_op = cpu_to_be32(op);
+ return key;
+}
+
+static void orph_key_test_and_del(const struct lu_context *ctx,
+ struct mdd_device *mdd,
+ const struct orph_key *key)
+{
+ struct mdd_object *mdo;
+
+ mdo = mdd_object_find(ctx, mdd, &key->ok_fid);
+ if (IS_ERR(mdo))
+ CERROR("Invalid orphan!\n");
+ else {
+ if (mdo->mod_count == 0) {
+ /* non-opened orphan, let's delete it */
+ struct md_attr *ma = &mdd_ctx_info(ctx)->mti_ma;
+ __mdd_object_kill(ctx, mdo, ma);
+ /* TODO: now handle OST objects */
+ //mdd_ost_objects_destroy(ctx, ma);
+ /* TODO: destroy index entry */
+ }
+ mdd_object_put(ctx, mdo);
+ }
+}
+
+static int orph_index_iterate(const struct lu_context *ctx,
+ struct mdd_device *mdd)
+{
+ struct dt_object *dt_obj = mdd->mdd_orphans;
+ struct dt_it *it;
+ struct dt_it_ops *iops;
+ struct orph_key *key = orph_key_empty(ctx, 0);
+ int result;