+ LINVRNT(osd_invariant(obj));
+ LASSERT(obj->oo_inode == NULL);
+ LASSERTF(fid_is_sane(fid) || fid_is_idif(fid), DFID, PFID(fid));
+
+ dev = osd_dev(ldev);
+ scrub = &dev->od_scrub;
+ sf = &scrub->os_file;
+ info = osd_oti_get(env);
+ LASSERT(info);
+ oic = &info->oti_cache;
+ id = &oic->oic_lid;
+
+ if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOENT))
+ RETURN(-ENOENT);
+
+ if (fid_is_norm(fid)) {
+ /* Search order: 1. per-thread cache. */
+ if (lu_fid_eq(fid, &oic->oic_fid)) {
+ goto iget;
+ } else if (!cfs_list_empty(&scrub->os_inconsistent_items)) {
+ /* Search order: 2. OI scrub pending list. */
+ result = osd_oii_lookup(dev, fid, id);
+ if (result == 0)
+ goto iget;
+ }
+
+ if (sf->sf_flags & SF_INCONSISTENT)
+ verify = 1;
+ }
+
+ /*
+ * Objects are created as locking anchors or place holders for objects
+ * yet to be created. No need to osd_oi_lookup() at here because FID
+ * shouldn't never be re-used, if it's really a duplicate FID from
+ * unexpected reason, we should be able to detect it later by calling
+ * do_create->osd_oi_insert()
+ */
+ if (conf != NULL && (conf->loc_flags & LOC_F_NEW) != 0)
+ GOTO(out, result = 0);
+
+ /* Search order: 3. OI files. */
+ result = osd_oi_lookup(info, dev, fid, id);
+ if (result == -ENOENT) {
+ if (!fid_is_norm(fid) ||
+ !ldiskfs_test_bit(osd_oi_fid2idx(dev,fid),
+ sf->sf_oi_bitmap))
+ GOTO(out, result = 0);
+
+ goto trigger;
+ }
+
+ if (result != 0)
+ GOTO(out, result);
+
+iget:
+ if (verify == 0)
+ inode = osd_iget(info, dev, id);
+ else
+ inode = osd_iget_verify(info, dev, id, fid);
+ if (IS_ERR(inode)) {
+ result = PTR_ERR(inode);
+ if (result == -ENOENT || result == -ESTALE) {
+ fid_zero(&oic->oic_fid);
+ result = 0;
+ } else if (result == -EREMCHG) {
+
+trigger:
+ if (thread_is_running(&scrub->os_thread)) {
+ result = -EINPROGRESS;
+ } else if (!scrub->os_no_scrub) {
+ result = osd_scrub_start(dev);
+ LCONSOLE_ERROR("%.16s: trigger OI scrub by RPC "
+ "for "DFID", rc = %d [1]\n",
+ LDISKFS_SB(osd_sb(dev))->s_es->\
+ s_volume_name,PFID(fid), result);
+ if (result == 0 || result == -EALREADY)
+ result = -EINPROGRESS;
+ else
+ result = -EREMCHG;
+ }
+ }