#include "libbcachefs/error.h"
#include "libbcachefs/fs-common.h"
#include "libbcachefs/inode.h"
-#include "libbcachefs/io.h"
+#include "libbcachefs/io_read.h"
+#include "libbcachefs/io_write.h"
#include "libbcachefs/opts.h"
#include "libbcachefs/super.h"
{
struct bch_fs *c = fuse_req_userdata(req);
struct bch_inode_unpacked inode_u;
- struct btree_trans trans;
+ struct btree_trans *trans;
struct btree_iter iter;
u64 now;
int ret;
fuse_log(FUSE_LOG_DEBUG, "bcachefs_fuse_setattr(%llu, %x)\n", inum.inum, to_set);
- bch2_trans_init(&trans, c, 0, 0);
+ trans = bch2_trans_get(c);
retry:
- bch2_trans_begin(&trans);
+ bch2_trans_begin(trans);
now = bch2_current_time(c);
- ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
+ ret = bch2_inode_peek(trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
if (ret)
goto err;
inode_u.bi_mtime = now;
/* TODO: CTIME? */
- ret = bch2_inode_write(&trans, &iter, &inode_u) ?:
- bch2_trans_commit(&trans, NULL, NULL,
+ ret = bch2_inode_write(trans, &iter, &inode_u) ?:
+ bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL);
err:
- bch2_trans_iter_exit(&trans, &iter);
+ bch2_trans_iter_exit(trans, &iter);
if (ret == -EINTR)
goto retry;
- bch2_trans_exit(&trans);
+ bch2_trans_put(trans);
if (!ret) {
*attr = inode_to_stat(c, &inode_u);
bch2_inode_init_early(c, new_inode);
return bch2_trans_do(c, NULL, NULL, 0,
- bch2_create_trans(&trans,
+ bch2_create_trans(trans,
dir, &dir_u,
new_inode, &qstr,
uid, gid, mode, rdev, NULL, NULL,
fuse_log(FUSE_LOG_DEBUG, "bcachefs_fuse_unlink(%llu, %s)\n", dir.inum, name);
int ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL,
- bch2_unlink_trans(&trans, dir, &dir_u,
+ bch2_unlink_trans(trans, dir, &dir_u,
&inode_u, &qstr, false));
fuse_reply_err(req, -ret);
/* XXX handle overwrites */
ret = bch2_trans_do(c, NULL, NULL, 0,
- bch2_rename_trans(&trans,
+ bch2_rename_trans(trans,
src_dir, &src_dir_u,
dst_dir, &dst_dir_u,
&src_inode_u, &dst_inode_u,
inum, newparent.inum, newname);
ret = bch2_trans_do(c, NULL, NULL, 0,
- bch2_link_trans(&trans, newparent, &dir_u,
+ bch2_link_trans(trans, newparent, &dir_u,
inum, &inode_u, &qstr));
if (!ret) {
static int inode_update_times(struct bch_fs *c, subvol_inum inum)
{
- struct btree_trans trans;
+ struct btree_trans *trans;
struct btree_iter iter;
struct bch_inode_unpacked inode_u;
int ret = 0;
u64 now;
- bch2_trans_init(&trans, c, 0, 0);
+ trans = bch2_trans_get(c);
retry:
- bch2_trans_begin(&trans);
+ bch2_trans_begin(trans);
now = bch2_current_time(c);
- ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
+ ret = bch2_inode_peek(trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
if (ret)
goto err;
inode_u.bi_mtime = now;
inode_u.bi_ctime = now;
- ret = bch2_inode_write(&trans, &iter, &inode_u);
+ ret = bch2_inode_write(trans, &iter, &inode_u);
if (ret)
goto err;
- ret = bch2_trans_commit(&trans, NULL, NULL,
+ ret = bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL);
err:
- bch2_trans_iter_exit(&trans, &iter);
+ bch2_trans_iter_exit(trans, &iter);
if (ret == -EINTR)
goto retry;
- bch2_trans_exit(&trans);
+ bch2_trans_put(trans);
return ret;
}