mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
bcachefs: Fix upgrade_readers()
The bch2_btree_path_upgrade() call was failing and tripping an assert - path->level + 1 is in this case not necessarily exactly what we want, fix it by upgrading exactly the locks we want. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
d740729272
commit
f527afea5a
@ -180,8 +180,8 @@ bool __bch2_btree_node_relock(struct btree_trans *trans,
|
||||
}
|
||||
}
|
||||
|
||||
static bool bch2_btree_node_upgrade(struct btree_trans *trans,
|
||||
struct btree_path *path, unsigned level)
|
||||
bool bch2_btree_node_upgrade(struct btree_trans *trans,
|
||||
struct btree_path *path, unsigned level)
|
||||
{
|
||||
struct btree *b = path->l[level].b;
|
||||
|
||||
|
@ -192,6 +192,9 @@ static inline int btree_trans_restart(struct btree_trans *trans)
|
||||
return -EINTR;
|
||||
}
|
||||
|
||||
bool bch2_btree_node_upgrade(struct btree_trans *,
|
||||
struct btree_path *, unsigned);
|
||||
|
||||
bool __bch2_btree_path_upgrade(struct btree_trans *,
|
||||
struct btree_path *, unsigned);
|
||||
|
||||
|
@ -507,6 +507,15 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void path_upgrade_readers(struct btree_trans *trans, struct btree_path *path)
|
||||
{
|
||||
unsigned l;
|
||||
|
||||
for (l = 0; l < BTREE_MAX_DEPTH; l++)
|
||||
if (btree_node_read_locked(path, l))
|
||||
BUG_ON(!bch2_btree_node_upgrade(trans, path, l));
|
||||
}
|
||||
|
||||
static inline void upgrade_readers(struct btree_trans *trans, struct btree_path *path)
|
||||
{
|
||||
struct btree *b = path_l(path)->b;
|
||||
@ -514,7 +523,7 @@ static inline void upgrade_readers(struct btree_trans *trans, struct btree_path
|
||||
do {
|
||||
if (path->nodes_locked &&
|
||||
path->nodes_locked != path->nodes_intent_locked)
|
||||
BUG_ON(!bch2_btree_path_upgrade(trans, path, path->level + 1));
|
||||
path_upgrade_readers(trans, path);
|
||||
} while ((path = prev_btree_path(trans, path)) &&
|
||||
path_l(path)->b == b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user