+static int out_tx_destroy_exec(const struct lu_env *env, struct thandle *th,
+ struct tx_arg *arg)
+{
+ struct dt_object *dt_obj = arg->object;
+ int rc;
+
+ rc = out_obj_destroy(env, dt_obj, th);
+
+ CDEBUG(D_INFO, "%s: insert destroy reply %p index %d: rc = %d\n",
+ dt_obd_name(th->th_dev), arg->reply, arg->index, rc);
+
+ update_insert_reply(arg->reply, NULL, 0, arg->index, rc);
+
+ RETURN(rc);
+}
+
+static int out_tx_destroy_undo(const struct lu_env *env, struct thandle *th,
+ struct tx_arg *arg)
+{
+ CERROR("%s: not support destroy undo yet!: rc = %d\n",
+ dt_obd_name(th->th_dev), -ENOTSUPP);
+ return -ENOTSUPP;
+}
+
+static int __out_tx_destroy(const struct lu_env *env, struct dt_object *dt_obj,
+ struct thandle_exec_args *th,
+ struct update_reply *reply,
+ int index, char *file, int line)
+{
+ struct tx_arg *arg;
+
+ LASSERT(th->ta_handle != NULL);
+ th->ta_err = dt_declare_destroy(env, dt_obj, th->ta_handle);
+ if (th->ta_err)
+ return th->ta_err;
+
+ arg = tx_add_exec(th, out_tx_destroy_exec, out_tx_destroy_undo,
+ file, line);
+ LASSERT(arg);
+ lu_object_get(&dt_obj->do_lu);
+ arg->object = dt_obj;
+ arg->reply = reply;
+ arg->index = index;
+ return 0;
+}
+
+static int out_destroy(struct out_thread_info *info)
+{
+ struct update *update = info->mti_u.update.mti_update;
+ struct dt_object *obj = info->mti_u.update.mti_dt_object;
+ struct lu_fid *fid;
+ int rc;
+ ENTRY;
+
+ fid = &update->u_fid;
+ fid_le_to_cpu(fid, fid);
+ if (!fid_is_sane(fid)) {
+ CERROR("%s: invalid FID "DFID": rc = %d\n",
+ mdt_obd_name(info->mti_mdt), PFID(fid), -EPROTO);
+ RETURN(err_serious(-EPROTO));
+ }
+
+ if (!lu_object_exists(&obj->do_lu))
+ RETURN(-ENOENT);
+
+ rc = out_tx_destroy(info->mti_env, obj, &info->mti_handle,
+ info->mti_u.update.mti_update_reply,
+ info->mti_u.update.mti_update_reply_index);
+
+ RETURN(rc);
+}
+