- CDEBUG(D_LFSCK, "%s: layout LFSCK assistant found dangling "
- "reference for: parent "DFID", child "DFID", OST-index %u, "
- "stripe-index %u, owner %u/%u. %s: rc = %d\n",
- lfsck_lfsck2name(com->lc_lfsck), PFID(lfsck_dto2fid(parent)),
- PFID(lfsck_dto2fid(child)), llr->llr_ost_idx,
- llr->llr_lov_idx, pla->la_uid, pla->la_gid,
- create ? "Create the lost OST-object as required" :
- "Keep the MDT-object there by default", rc);
+ if (rc != 0 && log)
+ CDEBUG(D_LFSCK, "%s: layout LFSCK assistant found "
+ "dangling reference for: parent "DFID", child "
+ DFID", ea_off %u, ost_idx %u, %s: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(pfid), PFID(cfid),
+ ea_off, ost_idx,
+ (lfsck->li_bookmark_ram.lb_param & LPF_CREATE_OSTOBJ) ?
+ "Create the lost OST-object as required" :
+ "Keep the MDT-object there by default", rc);
+
+ return rc;
+}
+
+/**
+ * Repair the MDT-object with dangling LOV EA reference.
+ *
+ * Prepare parameters and call __lfsck_layout_repair_dangling()
+ * to repair the dangling LOV EA reference.
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] com the layout LFSCK component
+ * \param[in] pfid the MDT-object's FID
+ * \param[in] cfid the FID for the OST-object to be created
+ * \param[in] ea_off the offset of the OST-object in the LOV EA
+ * \param[in] ost_idx the index of OST on which the OST-object resides
+ *
+ * \retval +1 for repair successfully
+ * \retval 0 for did nothing
+ * \retval negative error number on failure
+ */
+static int lfsck_layout_repair_dangling(const struct lu_env *env,
+ struct lfsck_component *com,
+ const struct lu_fid *pfid,
+ const struct lu_fid *cfid,
+ __u32 ea_off, __u32 ost_idx)
+{
+ struct lfsck_instance *lfsck = com->lc_lfsck;
+ struct dt_object *parent = NULL;
+ struct dt_object *child = NULL;
+ struct lfsck_tgt_desc *ltd;
+ int rc;
+ ENTRY;
+
+ parent = lfsck_object_find_bottom(env, lfsck, pfid);
+ if (IS_ERR(parent))
+ GOTO(log, rc = PTR_ERR(parent));
+
+ /* The MDT-object has been removed. */
+ if (dt_object_exists(parent) == 0)
+ GOTO(log, rc = 0);
+
+ ltd = lfsck_ltd2tgt(&lfsck->li_ost_descs, ost_idx);
+ if (unlikely(ltd == NULL))
+ GOTO(log, rc = -ENODEV);
+
+ child = lfsck_object_find_by_dev(env, ltd->ltd_tgt, cfid);
+ if (IS_ERR(child))
+ GOTO(log, rc = PTR_ERR(child));
+
+ /* The OST-object has been created. */
+ if (unlikely(dt_object_exists(child) != 0))
+ GOTO(log, rc = 0);
+
+ rc = __lfsck_layout_repair_dangling(env, com, parent, child,
+ ea_off, ost_idx, false);
+
+ GOTO(log, rc);
+
+log:
+ if (child != NULL && !IS_ERR(child))
+ lfsck_object_put(env, child);
+
+ if (parent != NULL && !IS_ERR(parent))
+ lfsck_object_put(env, parent);
+
+ if (rc != 0)
+ CDEBUG(D_LFSCK, "%s: layout LFSCK assistant found "
+ "dangling reference for: parent "DFID", child "
+ DFID", ea_off %u, ost_idx %u, %s: rc = %d\n",
+ lfsck_lfsck2name(lfsck), PFID(pfid), PFID(cfid),
+ ea_off, ost_idx,
+ (lfsck->li_bookmark_ram.lb_param & LPF_CREATE_OSTOBJ) ?
+ "Create the lost OST-object as required" :
+ "Keep the MDT-object there by default", rc);