+static int mdd_dom_data_truncate(const struct lu_env *env,
+ struct mdd_device *mdd, struct mdd_object *mo)
+{
+ struct thandle *th;
+ struct dt_object *dom;
+ int rc;
+
+ dom = dt_object_locate(mdd_object_child(mo), mdd->mdd_bottom);
+ if (!dom)
+ GOTO(out, rc = -ENODATA);
+
+ th = dt_trans_create(env, mdd->mdd_bottom);
+ if (IS_ERR(th))
+ GOTO(out, rc = PTR_ERR(th));
+
+ rc = dt_declare_punch(env, dom, 0, OBD_OBJECT_EOF, th);
+ if (rc)
+ GOTO(stop, rc);
+
+ rc = dt_trans_start_local(env, mdd->mdd_bottom, th);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ rc = dt_punch(env, dom, 0, OBD_OBJECT_EOF, th);
+stop:
+ dt_trans_stop(env, mdd->mdd_bottom, th);
+out:
+ /* Ignore failure but report the error */
+ if (rc)
+ CERROR("%s: "DFID" can't truncate DOM inode data, rc = %d\n",
+ mdd_obj_dev_name(mo), PFID(mdo2fid(mo)), rc);
+ return rc;
+}
+