Beispiel #1
0
static int __out_tx_create(const struct lu_env *env, struct dt_object *obj,
			   struct lu_attr *attr, struct lu_fid *parent_fid,
			   struct dt_object_format *dof,
			   struct thandle_exec_args *ta,
			   struct update_reply *reply,
			   int index, char *file, int line)
{
	struct tx_arg *arg;

	LASSERT(ta->ta_handle != NULL);
	ta->ta_err = dt_declare_create(env, obj, attr, NULL, dof,
				       ta->ta_handle);
	if (ta->ta_err != 0)
		return ta->ta_err;

	arg = tx_add_exec(ta, out_tx_create_exec, out_tx_create_undo, file,
			  line);
	LASSERT(arg);

	/* release the object in out_trans_stop */
	lu_object_get(&obj->do_lu);
	arg->object = obj;
	arg->u.create.attr = *attr;
	if (parent_fid)
		arg->u.create.fid = *parent_fid;
	memset(&arg->u.create.hint, 0, sizeof(arg->u.create.hint));
	arg->u.create.dof  = *dof;
	arg->reply = reply;
	arg->index = index;

	return 0;
}
Beispiel #2
0
static int __out_tx_xattr_set(const struct lu_env *env,
			      struct dt_object *dt_obj,
			      const struct lu_buf *buf,
			      const char *name, int flags,
			      struct thandle_exec_args *ta,
			      struct update_reply *reply, int index,
			      char *file, int line)
{
	struct tx_arg		*arg;

	LASSERT(ta->ta_handle != NULL);
	ta->ta_err = dt_declare_xattr_set(env, dt_obj, buf, name,
					  flags, ta->ta_handle);
	if (ta->ta_err != 0)
		return ta->ta_err;

	arg = tx_add_exec(ta, out_tx_xattr_set_exec, NULL, file, line);
	LASSERT(arg);
	lu_object_get(&dt_obj->do_lu);
	arg->object = dt_obj;
	arg->u.xattr_set.name = name;
	arg->u.xattr_set.flags = flags;
	arg->u.xattr_set.buf = *buf;
	arg->reply = reply;
	arg->index = index;
	arg->u.xattr_set.csum = 0;
	return 0;
}
Beispiel #3
0
static int __out_tx_index_delete(const struct lu_env *env,
				 struct dt_object *dt_obj, char *name,
				 struct thandle_exec_args *ta,
				 struct update_reply *reply,
				 int index, char *file, int line)
{
	struct tx_arg *arg;

	if (dt_try_as_dir(env, dt_obj) == 0) {
		ta->ta_err = -ENOTDIR;
		return ta->ta_err;
	}

	LASSERT(ta->ta_handle != NULL);
	ta->ta_err = dt_declare_delete(env, dt_obj,
				       (struct dt_key *)name,
				       ta->ta_handle);
	if (ta->ta_err != 0)
		return ta->ta_err;

	arg = tx_add_exec(ta, out_tx_index_delete_exec,
			  out_tx_index_delete_undo, file,
			  line);
	LASSERT(arg);
	lu_object_get(&dt_obj->do_lu);
	arg->object = dt_obj;
	arg->reply = reply;
	arg->index = index;
	arg->u.insert.key = (struct dt_key *)name;
	return 0;
}
Beispiel #4
0
static int __out_tx_write(const struct lu_env *env,
			  struct dt_object *dt_obj,
			  const struct lu_buf *buf,
			  loff_t pos, struct thandle_exec_args *ta,
			  struct object_update_reply *reply,
			  int index, char *file, int line)
{
	struct tx_arg	*arg;

	LASSERT(ta->ta_handle != NULL);
	ta->ta_err = dt_declare_record_write(env, dt_obj, buf, pos,
					     ta->ta_handle);
	if (ta->ta_err != 0)
		return ta->ta_err;

	arg = tx_add_exec(ta, out_tx_write_exec, NULL, file, line);
	LASSERT(arg);
	lu_object_get(&dt_obj->do_lu);
	arg->object = dt_obj;
	arg->u.write.buf = *buf;
	arg->u.write.pos = pos;
	arg->reply = reply;
	arg->index = index;
	return 0;
}
Beispiel #5
0
static int __out_tx_attr_set(struct mdt_thread_info *info,
			     struct dt_object *dt_obj,
			     const struct lu_attr *attr,
			     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_attr_set(info->mti_env, dt_obj, attr,
					 th->ta_handle);
	if (th->ta_err != 0)
		return th->ta_err;

	arg = tx_add_exec(th, out_tx_attr_set_exec, out_tx_attr_set_undo,
			  file, line);
	LASSERT(arg);
	lu_object_get(&dt_obj->do_lu);
	arg->object = dt_obj;
	arg->u.attr_set.attr = *attr;
	arg->reply = reply;
	arg->index = index;
	return 0;
}
Beispiel #6
0
static int __out_tx_destroy(const struct lu_env *env, struct dt_object *dt_obj,
			     struct thandle_exec_args *ta,
			     struct update_reply *reply,
			     int index, char *file, int line)
{
	struct tx_arg *arg;

	LASSERT(ta->ta_handle != NULL);
	ta->ta_err = dt_declare_destroy(env, dt_obj, ta->ta_handle);
	if (ta->ta_err)
		return ta->ta_err;

	arg = tx_add_exec(ta, 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;
}
Beispiel #7
0
static int __out_tx_index_insert(struct mdt_thread_info *info,
				 struct dt_object *dt_obj,
				 char *name, struct lu_fid *fid,
				 struct thandle_exec_args *th,
				 struct update_reply *reply,
				 int index, char *file, int line)
{
	struct tx_arg *arg;

	LASSERT(th->ta_handle != NULL);

	if (lu_object_exists(&dt_obj->do_lu)) {
		if (dt_try_as_dir(info->mti_env, dt_obj) == 0) {
			th->ta_err = -ENOTDIR;
			return th->ta_err;
		}
		th->ta_err = dt_declare_insert(info->mti_env, dt_obj,
					       (struct dt_rec *)fid,
					       (struct dt_key *)name,
					       th->ta_handle);
	}

	if (th->ta_err != 0)
		return th->ta_err;

	arg = tx_add_exec(th, out_tx_index_insert_exec,
			  out_tx_index_insert_undo, file,
			  line);
	LASSERT(arg);
	lu_object_get(&dt_obj->do_lu);
	arg->object = dt_obj;
	arg->reply = reply;
	arg->index = index;
	arg->u.insert.rec = (struct dt_rec *)fid;
	arg->u.insert.key = (struct dt_key *)name;

	return 0;
}