summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-03-13 01:52:42 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:55 +0300
commit5f0e4ae1c73efe9e4f74492df08202a5845bd19a (patch)
treea1d4db3a4241f5af9c3c99fa01488cd1fa5a6010 /fs/bcachefs/fs.c
parentb3b66e30445e42a94fa171fad99e0b4e4e43c1ac (diff)
downloadlinux-5f0e4ae1c73efe9e4f74492df08202a5845bd19a.tar.xz
bcachefs: Use __bch2_trans_do() in a few more places
Minor cleanup, it was being open coded. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs.c')
-rw-r--r--fs/bcachefs/fs.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 2d5e00a42b3e..a168d09ffd37 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -416,16 +416,12 @@ static int __bch2_link(struct bch_fs *c,
mutex_lock(&inode->ei_update_lock);
bch2_trans_init(&trans, c, 4, 1024);
- do {
- bch2_trans_begin(&trans);
- ret = bch2_link_trans(&trans,
+ ret = __bch2_trans_do(&trans, NULL, &inode->ei_journal_seq,
+ BTREE_INSERT_NOUNLOCK,
+ bch2_link_trans(&trans,
dir->v.i_ino,
inode->v.i_ino, &dir_u, &inode_u,
- &dentry->d_name) ?:
- bch2_trans_commit(&trans, NULL,
- &inode->ei_journal_seq,
- BTREE_INSERT_NOUNLOCK);
- } while (ret == -EINTR);
+ &dentry->d_name));
if (likely(!ret)) {
BUG_ON(inode_u.bi_inum != inode->v.i_ino);
@@ -472,17 +468,12 @@ static int bch2_unlink(struct inode *vdir, struct dentry *dentry)
bch2_lock_inodes(INODE_UPDATE_LOCK, dir, inode);
bch2_trans_init(&trans, c, 4, 1024);
- do {
- bch2_trans_begin(&trans);
-
- ret = bch2_unlink_trans(&trans,
+ ret = __bch2_trans_do(&trans, NULL, &dir->ei_journal_seq,
+ BTREE_INSERT_NOUNLOCK|
+ BTREE_INSERT_NOFAIL,
+ bch2_unlink_trans(&trans,
dir->v.i_ino, &dir_u,
- &inode_u, &dentry->d_name) ?:
- bch2_trans_commit(&trans, NULL,
- &dir->ei_journal_seq,
- BTREE_INSERT_NOUNLOCK|
- BTREE_INSERT_NOFAIL);
- } while (ret == -EINTR);
+ &inode_u, &dentry->d_name));
if (likely(!ret)) {
BUG_ON(inode_u.bi_inum != inode->v.i_ino);
@@ -599,21 +590,16 @@ static int bch2_rename2(struct mnt_idmap *idmap,
goto err;
}
-retry:
- bch2_trans_begin(&trans);
- ret = bch2_rename_trans(&trans,
- src_dir->v.i_ino, &src_dir_u,
- dst_dir->v.i_ino, &dst_dir_u,
- &src_inode_u,
- &dst_inode_u,
- &src_dentry->d_name,
- &dst_dentry->d_name,
- mode) ?:
- bch2_trans_commit(&trans, NULL,
- &journal_seq,
- BTREE_INSERT_NOUNLOCK);
- if (ret == -EINTR)
- goto retry;
+ ret = __bch2_trans_do(&trans, NULL, &journal_seq,
+ BTREE_INSERT_NOUNLOCK,
+ bch2_rename_trans(&trans,
+ src_dir->v.i_ino, &src_dir_u,
+ dst_dir->v.i_ino, &dst_dir_u,
+ &src_inode_u,
+ &dst_inode_u,
+ &src_dentry->d_name,
+ &dst_dentry->d_name,
+ mode));
if (unlikely(ret))
goto err;