+static int __lfsck_layout_update_pfid(const struct lu_env *env,
+ struct dt_object *child,
+ const struct lu_fid *pfid, __u32 offset)
+{
+ struct dt_device *dev = lfsck_obj2dev(child);
+ struct filter_fid *ff = &lfsck_env_info(env)->lti_new_pfid;
+ struct thandle *handle;
+ struct lu_buf buf = { NULL };
+ int rc;
+
+ ff->ff_parent.f_seq = cpu_to_le64(pfid->f_seq);
+ ff->ff_parent.f_oid = cpu_to_le32(pfid->f_oid);
+ /* Currently, the filter_fid::ff_parent::f_ver is not the real parent
+ * MDT-object's FID::f_ver, instead it is the OST-object index in its
+ * parent MDT-object's layout EA. */
+ ff->ff_parent.f_stripe_idx = cpu_to_le32(offset);
+ lfsck_buf_init(&buf, ff, sizeof(struct filter_fid));
+
+ handle = dt_trans_create(env, dev);
+ if (IS_ERR(handle))
+ RETURN(PTR_ERR(handle));
+
+ rc = dt_declare_xattr_set(env, child, &buf, XATTR_NAME_FID, 0, handle);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_trans_start_local(env, dev, handle);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_xattr_set(env, child, &buf, XATTR_NAME_FID, 0, handle,
+ BYPASS_CAPA);
+
+ GOTO(stop, rc);
+
+stop:
+ dt_trans_stop(env, dev, handle);
+
+ return rc;
+}
+