+ 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",
+ mdd2obd_dev(mdd)->obd_name);
+ /* Index contains no zero key? */
+ GOTO(out_put, rc = -EIO);
+ }
+
+ 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 PENDING\n",
+ mdd2obd_dev(mdd)->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 *)ent->lde_name);
+
+ /* after index delete reset iterator */
+ if (rc == 0)
+ rc = iops->get(env, it, (const void *)"");
+ else
+ rc = iops->load(env, it, cookie);
+next:
+ rc = iops->next(env, it);
+ } while (rc == 0);
+
+ GOTO(out_put, rc = 0);
+out_put:
+ iops->put(env, it);
+ iops->fini(env, it);
+
+out:
+ return rc;