diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-07-30 18:01:33 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2021-07-30 18:06:34 -0400 |
commit | 6fd8b4b9fbaac9af88e094831ee9a22708d8bba8 (patch) | |
tree | 59fa2a490c7d8cd7c3c16a105b39c79bed9eca00 | |
parent | 57987362ebb5613785d29b0a7f432669b423bf59 (diff) |
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>
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index e9e542260bff..7e9909e2dcaf 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1041,7 +1041,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); - *i = n; + + /* + * 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); |