- struct dt_object *dor = mdd->mdd_orphans;
- char *mti_key = mdd_env_info(env)->mti_orph_key;
- const struct dt_it_ops *iops;
- struct dt_it *it;
- char *key;
- struct lu_fid fid;
- int result = 0;
- int key_sz = 0;
- int rc;
- __u64 cookie;
- ENTRY;
-
- /* In recovery phase, do not need for any lock here */
- iops = &dor->do_index_ops->dio_it;
- it = iops->init(env, dor, LUDA_64BITHASH, BYPASS_CAPA);
- if (IS_ERR(it)) {
- rc = PTR_ERR(it);
- CERROR("%s: cannot clean PENDING: rc = %d\n",
- mdd->mdd_obd_dev->obd_name, rc);
- GOTO(out, rc);
- }
-
- rc = iops->load(env, it, 0);
- if (rc < 0)
- GOTO(out_put, rc);
- if (rc == 0) {
- CERROR("%s: error loading iterator to clean PENDING\n",
- mdd->mdd_obd_dev->obd_name);
- /* Index contains no zero key? */
- GOTO(out_put, rc = -EIO);
- }
-
- do {
- key = (void *)iops->key(env, it);
- if (IS_ERR(key)) {
- CERROR("%s: key failed when clean PENDING: rc = %ld\n",
- mdd->mdd_obd_dev->obd_name, PTR_ERR(key));
- goto next;
- }
- key_sz = iops->key_size(env, it);
-
- /* filter out "." and ".." entries from PENDING dir. */
- if (key_sz < 8)
- goto next;
-
- memcpy(mti_key, key, key_sz);
- mti_key[key_sz] = 0;
-
- if (orphan_key_to_fid(mti_key, &fid))
- goto next;
- if (!fid_is_sane(&fid)) {
- CERROR("%s: bad FID "DFID" cleaning PENDING\n",
- mdd->mdd_obd_dev->obd_name, PFID(&fid));
- goto next;
- }
-
- /* kill orphan object */
- cookie = iops->store(env, it);
- iops->put(env, it);
- rc = orph_key_test_and_del(env, mdd, &fid,
- (struct dt_key *)mti_key);
-
- /* after index delete reset iterator */
- if (rc == 0)
- result = iops->get(env, it, (const void *)"");
- else
- result = iops->load(env, it, cookie);
+ struct mdd_device *mdd = (struct mdd_device *)thread->mgt_data;
+ struct dt_object *dor = mdd->mdd_orphans;
+ struct lu_dirent *ent = &mdd_env_info(env)->mti_ent;
+ const struct dt_it_ops *iops;
+ struct dt_it *it;
+ struct lu_fid fid;
+ int key_sz = 0;
+ int rc;
+ ENTRY;
+
+ iops = &dor->do_index_ops->dio_it;
+ it = iops->init(env, dor, LUDA_64BITHASH);
+ if (IS_ERR(it)) {
+ rc = PTR_ERR(it);
+ CERROR("%s: cannot clean '%s': rc = %d\n",
+ mdd2obd_dev(mdd)->obd_name, mdd_orphan_index_name, rc);
+ GOTO(out, rc);
+ }
+
+ rc = iops->load(env, it, 0);
+ if (rc < 0)
+ GOTO(out_put, rc);
+ if (rc == 0) {
+ CERROR("%s: error loading iterator to clean '%s'\n",
+ mdd2obd_dev(mdd)->obd_name, mdd_orphan_index_name);
+ /* Index contains no zero key? */
+ GOTO(out_put, rc = -EIO);
+ }
+
+ mdd_env_info(env)->mti_flags |= MTI_KEEP_KEY;
+ do {
+ if (thread->mgt_abort)
+ break;
+
+ key_sz = iops->key_size(env, it);
+ /* filter out "." and ".." entries from PENDING dir. */
+ if (key_sz < 8)
+ goto next;
+
+ rc = iops->rec(env, it, (struct dt_rec *)ent, LUDA_64BITHASH);
+ if (rc != 0) {
+ CERROR("%s: fail to get FID for orphan it: rc = %d\n",
+ mdd2obd_dev(mdd)->obd_name, rc);
+ goto next;
+ }
+
+ fid_le_to_cpu(&fid, &ent->lde_fid);
+ if (!fid_is_sane(&fid)) {
+ CERROR("%s: bad FID "DFID" cleaning '%s'\n",
+ mdd2obd_dev(mdd)->obd_name, PFID(&fid),
+ mdd_orphan_index_name);
+ goto next;
+ }
+
+ /* kill orphan object */
+ iops->put(env, it);
+ rc = mdd_orphan_key_test_and_delete(env, mdd, &fid,
+ (struct dt_key *)ent->lde_name);
+ /* after index delete reset iterator */
+ if (rc == 0)
+ rc = iops->get(env, it, (const void *)"");