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

bcachefs: Fix spurious -BCH_ERR_transaction_restart_nested

We only need to return transaction_restart_nested when we're inside a
context that's handling transaction restarts.

Also, add a missing check_subdir_count() call.

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

+21 -8
+21 -8
fs/bcachefs/fsck.c
··· 1114 1114 return ret; 1115 1115 } 1116 1116 1117 - static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w) 1117 + static int check_i_sectors_notnested(struct btree_trans *trans, struct inode_walker *w) 1118 1118 { 1119 1119 struct bch_fs *c = trans->c; 1120 - u32 restart_count = trans->restart_count; 1121 1120 int ret = 0; 1122 1121 s64 count2; 1123 1122 ··· 1148 1149 } 1149 1150 fsck_err: 1150 1151 bch_err_fn(c, ret); 1151 - return ret ?: trans_was_restarted(trans, restart_count); 1152 + return ret; 1153 + } 1154 + 1155 + static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w) 1156 + { 1157 + u32 restart_count = trans->restart_count; 1158 + return check_i_sectors_notnested(trans, w) ?: 1159 + trans_was_restarted(trans, restart_count); 1152 1160 } 1153 1161 1154 1162 struct extent_end { ··· 1539 1533 check_extent(trans, &iter, k, &w, &s, &extent_ends) ?: 1540 1534 check_extent_overbig(trans, &iter, k); 1541 1535 })) ?: 1542 - check_i_sectors(trans, &w)); 1536 + check_i_sectors_notnested(trans, &w)); 1543 1537 1544 1538 bch2_disk_reservation_put(c, &res); 1545 1539 extent_ends_exit(&extent_ends); ··· 1569 1563 return ret; 1570 1564 } 1571 1565 1572 - static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w) 1566 + static int check_subdir_count_notnested(struct btree_trans *trans, struct inode_walker *w) 1573 1567 { 1574 1568 struct bch_fs *c = trans->c; 1575 - u32 restart_count = trans->restart_count; 1576 1569 int ret = 0; 1577 1570 s64 count2; 1578 1571 ··· 1603 1598 } 1604 1599 fsck_err: 1605 1600 bch_err_fn(c, ret); 1606 - return ret ?: trans_was_restarted(trans, restart_count); 1601 + return ret; 1602 + } 1603 + 1604 + static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w) 1605 + { 1606 + u32 restart_count = trans->restart_count; 1607 + return check_subdir_count_notnested(trans, w) ?: 1608 + trans_was_restarted(trans, restart_count); 1607 1609 } 1608 1610 1609 1611 static int check_dirent_inode_dirent(struct btree_trans *trans, ··· 2015 2003 k, 2016 2004 NULL, NULL, 2017 2005 BCH_TRANS_COMMIT_no_enospc, 2018 - check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s))); 2006 + check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)) ?: 2007 + check_subdir_count_notnested(trans, &dir)); 2019 2008 2020 2009 snapshots_seen_exit(&s); 2021 2010 inode_walker_exit(&dir);