+static inline int osd_scrub_has_window(struct osd_scrub *scrub,
+ struct osd_otable_cache *ooc)
+{
+ return scrub->os_pos_current < ooc->ooc_pos_preload + SCRUB_WINDOW_SIZE;
+}
+
+static int osd_scrub_refresh_mapping(struct osd_thread_info *info,
+ struct osd_device *dev,
+ const struct lu_fid *fid,
+ const struct osd_inode_id *id, int ops)
+{
+ struct lu_fid *oi_fid = &info->oti_fid2;
+ struct osd_inode_id *oi_id = &info->oti_id2;
+ struct iam_container *bag;
+ struct iam_path_descr *ipd;
+ handle_t *jh;
+ int rc;
+ ENTRY;
+
+ fid_cpu_to_be(oi_fid, fid);
+ osd_id_pack(oi_id, id);
+ jh = ldiskfs_journal_start_sb(osd_sb(dev),
+ osd_dto_credits_noquota[ops]);
+ if (IS_ERR(jh)) {
+ rc = PTR_ERR(jh);
+ CERROR("%.16s: fail to start trans for scrub store: rc = %d\n",
+ LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, rc);
+ RETURN(rc);
+ }
+
+ bag = &osd_fid2oi(dev, fid)->oi_dir.od_container;
+ ipd = osd_idx_ipd_get(info->oti_env, bag);
+ if (unlikely(ipd == NULL)) {
+ ldiskfs_journal_stop(jh);
+ CERROR("%.16s: fail to get ipd for scrub store\n",
+ LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name);
+ RETURN(-ENOMEM);
+ }
+
+ if (ops == DTO_INDEX_UPDATE) {
+ rc = iam_update(jh, bag, (const struct iam_key *)oi_fid,
+ (struct iam_rec *)oi_id, ipd);
+ } else {
+ rc = iam_insert(jh, bag, (const struct iam_key *)oi_fid,
+ (struct iam_rec *)oi_id, ipd);
+ if (rc == -EEXIST) {
+ rc = 1;
+ /* XXX: There are trouble things when adding OI
+ * mapping for IGIF object, which may cause
+ * multiple objects to be mapped to the same
+ * IGIF formatted FID. Consider the following
+ * situations:
+ *
+ * 1) The MDT is upgrading from 1.8 device.
+ * The OI scrub generates IGIF FID1 for the
+ * OBJ1 and adds the OI mapping.
+ *
+ * 2) For some reason, the OI scrub does not
+ * process all the IGIF objects completely.
+ *
+ * 3) The MDT is backuped and restored against
+ * this device.
+ *
+ * 4) When the MDT mounts up, the OI scrub will
+ * try to rebuild the OI files. For some IGIF
+ * object, OBJ2, which was not processed by the
+ * OI scrub before the backup/restore, and the
+ * new generated IGIF formatted FID may be just
+ * the FID1, the same as OBJ1.
+ *
+ * Under such case, the OI scrub cannot know how
+ * to generate new FID for the OBJ2.
+ *
+ * Currently, we do nothing for that. One possible
+ * solution is to generate new normal FID for the
+ * conflict object.
+ *
+ * Anyway, it is rare, only exists in theory. */
+ }
+ }
+ osd_ipd_put(info->oti_env, bag, ipd);
+ ldiskfs_journal_stop(jh);
+ RETURN(rc);
+}
+
+/* OI_scrub file ops */
+