Skip to content

Commit 57f2d20

Browse files
author
Kent Overstreet
committed
bcachefs: Reduce would_deadlock restarts
We don't have to take locks in any particular ordering - we'll make forward progress just fine - but if we try to stick to an ordering, it can help to avoid excessive would_deadlock transaction restarts. This tweaks the reflink path to take extents btree locks in the right order. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 5b14ce3 commit 57f2d20

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/bcachefs/reflink.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,13 @@ s64 bch2_remap_range(struct bch_fs *c,
486486

487487
bch2_btree_iter_set_snapshot(&dst_iter, dst_snapshot);
488488

489+
if (dst_inum.inum < src_inum.inum) {
490+
/* Avoid some lock cycle transaction restarts */
491+
ret = bch2_btree_iter_traverse(&dst_iter);
492+
if (ret)
493+
continue;
494+
}
495+
489496
dst_done = dst_iter.pos.offset - dst_start.offset;
490497
src_want = POS(src_start.inode, src_start.offset + dst_done);
491498
bch2_btree_iter_set_pos(&src_iter, src_want);

0 commit comments

Comments
 (0)