Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: Fix missing transaction commit

In may_delete_deleted_inode(), there's a corner case when a snapshot was
taken while we had an unlinked inode: we don't want to delete the inode
in the internal (shared) snapshot node, since it might have been
reattached in a descendent snapshot.

Instead we propagate the key to any snapshot leaves it doesn't exist in,
so that it can be deleted there if necessary, and then clear the
unlinked flag in the internal node.

But we forgot to commit after clearing the unlinked flag, causing us to
go into an infinite loop.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+4 -2
+4 -2
fs/bcachefs/inode.c
··· 1169 1169 */ 1170 1170 for_each_btree_key(trans, iter, BTREE_ID_deleted_inodes, POS_MIN, 1171 1171 BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, ret) { 1172 - ret = lockrestart_do(trans, may_delete_deleted_inode(trans, &iter, k.k->p, 1173 - &need_another_pass)); 1172 + ret = commit_do(trans, NULL, NULL, 1173 + BTREE_INSERT_NOFAIL| 1174 + BTREE_INSERT_LAZY_RW, 1175 + may_delete_deleted_inode(trans, &iter, k.k->p, &need_another_pass)); 1174 1176 if (ret < 0) 1175 1177 break; 1176 1178