mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
bcachefs: Ensure that new inodes hit underlying btree
Inode creation is done with non-cached btree iterators, but then in the same transaction the inode may be updated again with a cached iterator - it makes cache coherency easier if new inodes always land in the underlying btree. This patch adds a check to bch2_trans_update() - if the same key is updated multiple times in the same transaction with both cached and non cache iterators, use the non cached iterator. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
0f120eac34
commit
e363726602
@ -1062,7 +1062,19 @@ int bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter,
|
||||
if (i < trans->updates + trans->nr_updates &&
|
||||
!btree_insert_entry_cmp(&n, i)) {
|
||||
BUG_ON(i->trans_triggers_run);
|
||||
|
||||
/*
|
||||
* This is a hack to ensure that inode creates update the btree,
|
||||
* not the key cache, which helps with cache coherency issues in
|
||||
* other areas:
|
||||
*/
|
||||
if (btree_iter_type(n.iter) == BTREE_ITER_CACHED &&
|
||||
btree_iter_type(i->iter) != BTREE_ITER_CACHED) {
|
||||
i->k = n.k;
|
||||
i->flags = n.flags;
|
||||
} else {
|
||||
*i = n;
|
||||
}
|
||||
} else
|
||||
array_insert_item(trans->updates, trans->nr_updates,
|
||||
i - trans->updates, n);
|
||||
|
Loading…
Reference in New Issue
Block a user