Commit fc88796d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: bch2_trans_update() now takes struct btree_insert_entry

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2ea90048
...@@ -375,7 +375,7 @@ int bch2_acl_chmod(struct btree_trans *trans, ...@@ -375,7 +375,7 @@ int bch2_acl_chmod(struct btree_trans *trans,
goto err; goto err;
} }
bch2_trans_update(trans, iter, &new->k_i, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(iter, &new->k_i));
*new_acl = acl; *new_acl = acl;
acl = NULL; acl = NULL;
err: err:
......
...@@ -140,8 +140,15 @@ int bch2_btree_node_update_key(struct bch_fs *, struct btree_iter *, ...@@ -140,8 +140,15 @@ int bch2_btree_node_update_key(struct bch_fs *, struct btree_iter *,
/* new transactional interface: */ /* new transactional interface: */
void bch2_trans_update(struct btree_trans *, struct btree_iter *, static inline void
struct bkey_i *, unsigned); bch2_trans_update(struct btree_trans *trans,
struct btree_insert_entry entry)
{
BUG_ON(trans->nr_updates >= ARRAY_SIZE(trans->updates));
trans->updates[trans->nr_updates++] = entry;
}
int bch2_trans_commit(struct btree_trans *, int bch2_trans_commit(struct btree_trans *,
struct disk_reservation *, struct disk_reservation *,
struct extent_insert_hook *, struct extent_insert_hook *,
......
...@@ -581,26 +581,6 @@ int __bch2_btree_insert_at(struct btree_insert *trans) ...@@ -581,26 +581,6 @@ int __bch2_btree_insert_at(struct btree_insert *trans)
goto out; goto out;
} }
void bch2_trans_update(struct btree_trans *trans,
struct btree_iter *iter,
struct bkey_i *k,
unsigned extra_journal_res)
{
struct btree_insert_entry *i;
BUG_ON(trans->nr_updates >= ARRAY_SIZE(trans->updates));
i = &trans->updates[trans->nr_updates++];
*i = (struct btree_insert_entry) {
.iter = iter,
.k = k,
.extra_res = extra_journal_res,
};
btree_insert_entry_checks(trans->c, i);
}
int bch2_trans_commit(struct btree_trans *trans, int bch2_trans_commit(struct btree_trans *trans,
struct disk_reservation *disk_res, struct disk_reservation *disk_res,
struct extent_insert_hook *hook, struct extent_insert_hook *hook,
......
...@@ -290,7 +290,9 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -290,7 +290,9 @@ int bch2_dirent_rename(struct btree_trans *trans,
* new_dst at the src position: * new_dst at the src position:
*/ */
new_dst->k.p = src_iter->pos; new_dst->k.p = src_iter->pos;
bch2_trans_update(trans, src_iter, &new_dst->k_i, 0); bch2_trans_update(trans,
BTREE_INSERT_ENTRY(src_iter,
&new_dst->k_i));
return 0; return 0;
} else { } else {
/* If we're overwriting, we can't insert new_dst /* If we're overwriting, we can't insert new_dst
...@@ -313,8 +315,8 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -313,8 +315,8 @@ int bch2_dirent_rename(struct btree_trans *trans,
} }
} }
bch2_trans_update(trans, src_iter, &new_src->k_i, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(src_iter, &new_src->k_i));
bch2_trans_update(trans, dst_iter, &new_dst->k_i, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(dst_iter, &new_dst->k_i));
return 0; return 0;
} }
......
...@@ -185,7 +185,7 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans, ...@@ -185,7 +185,7 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans,
return PTR_ERR(inode_p); return PTR_ERR(inode_p);
bch2_inode_pack(inode_p, inode_u); bch2_inode_pack(inode_p, inode_u);
bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(iter, &inode_p->inode.k_i));
return 0; return 0;
} }
......
...@@ -346,7 +346,8 @@ int __bch2_inode_create(struct btree_trans *trans, ...@@ -346,7 +346,8 @@ int __bch2_inode_create(struct btree_trans *trans,
inode_u->bi_generation = bkey_generation(k); inode_u->bi_generation = bkey_generation(k);
bch2_inode_pack(inode_p, inode_u); bch2_inode_pack(inode_p, inode_u);
bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0); bch2_trans_update(trans,
BTREE_INSERT_ENTRY(iter, &inode_p->inode.k_i));
return 0; return 0;
} }
} }
......
...@@ -255,14 +255,14 @@ static inline int __bch2_hash_set(struct btree_trans *trans, ...@@ -255,14 +255,14 @@ static inline int __bch2_hash_set(struct btree_trans *trans,
return -ENOENT; return -ENOENT;
insert->k.p = slot->pos; insert->k.p = slot->pos;
bch2_trans_update(trans, slot, insert, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(slot, insert));
return 0; return 0;
found: found:
if (flags & BCH_HASH_SET_MUST_CREATE) if (flags & BCH_HASH_SET_MUST_CREATE)
return -EEXIST; return -EEXIST;
insert->k.p = iter->pos; insert->k.p = iter->pos;
bch2_trans_update(trans, iter, insert, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(iter, insert));
return 0; return 0;
} }
...@@ -297,7 +297,7 @@ static inline int bch2_hash_delete_at(struct btree_trans *trans, ...@@ -297,7 +297,7 @@ static inline int bch2_hash_delete_at(struct btree_trans *trans,
delete->k.p = iter->pos; delete->k.p = iter->pos;
delete->k.type = ret ? desc.whiteout_type : KEY_TYPE_DELETED; delete->k.type = ret ? desc.whiteout_type : KEY_TYPE_DELETED;
bch2_trans_update(trans, iter, delete, 0); bch2_trans_update(trans, BTREE_INSERT_ENTRY(iter, delete));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment