-static int out_obj_index_insert(const struct lu_env *env,
- struct dt_object *dt_obj,
- const struct dt_rec *rec,
- const struct dt_key *key,
- struct thandle *th)
-{
- int rc;
-
- CDEBUG(D_INFO, "%s: index insert "DFID" name: %s fid "DFID"\n",
- dt_obd_name(th->th_dev), PFID(lu_object_fid(&dt_obj->do_lu)),
- (char *)key, PFID((struct lu_fid *)rec));
-
- if (dt_try_as_dir(env, dt_obj) == 0)
- return -ENOTDIR;
-
- dt_write_lock(env, dt_obj, MOR_TGT_CHILD);
- rc = dt_insert(env, dt_obj, rec, key, th, NULL, 0);
- dt_write_unlock(env, dt_obj);
-
- return rc;
-}
-
-static int out_obj_index_delete(const struct lu_env *env,
- struct dt_object *dt_obj,
- const struct dt_key *key,
- struct thandle *th)
-{
- int rc;
-
- CDEBUG(D_INFO, "%s: index delete "DFID" name: %s\n",
- dt_obd_name(th->th_dev), PFID(lu_object_fid(&dt_obj->do_lu)),
- (char *)key);
-
- if (dt_try_as_dir(env, dt_obj) == 0)
- return -ENOTDIR;
-
- dt_write_lock(env, dt_obj, MOR_TGT_CHILD);
- rc = dt_delete(env, dt_obj, key, th, NULL);
- dt_write_unlock(env, dt_obj);
-
- return rc;
-}
-
-static int out_tx_index_insert_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_index_insert(env, dt_obj, arg->u.insert.rec,
- arg->u.insert.key, th);
-
- CDEBUG(D_INFO, "%s: insert idx insert reply %p index %d: rc = %d\n",
- dt_obd_name(th->th_dev), arg->reply, arg->index, rc);
-
- object_update_result_insert(arg->reply, NULL, 0, arg->index, rc);
-
- return rc;
-}
-
-static int out_tx_index_insert_undo(const struct lu_env *env,
- struct thandle *th, struct tx_arg *arg)
-{
- return out_obj_index_delete(env, arg->object, arg->u.insert.key, th);
-}
-
-static int __out_tx_index_insert(const struct lu_env *env,
- struct dt_object *dt_obj,
- char *name, struct lu_fid *fid,
- 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);
-
- if (dt_try_as_dir(env, dt_obj) == 0) {
- ta->ta_err = -ENOTDIR;
- return ta->ta_err;
- }
-
- ta->ta_err = dt_declare_insert(env, dt_obj,
- (struct dt_rec *)fid,
- (struct dt_key *)name,
- ta->ta_handle);
-
- if (ta->ta_err != 0)
- return ta->ta_err;
-
- arg = tx_add_exec(ta, 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;
-}
-