Skip to content

Commit 109ea41

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent 3ff3475 commit 109ea41

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

fs/bcachefs/fsck.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,9 @@ int bch2_check_inodes(struct bch_fs *c)
11141114
return ret;
11151115
}
11161116

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)
11181118
{
11191119
struct bch_fs *c = trans->c;
1120-
u32 restart_count = trans->restart_count;
11211120
int ret = 0;
11221121
s64 count2;
11231122

@@ -1149,7 +1148,14 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
11491148
}
11501149
fsck_err:
11511150
bch_err_fn(c, ret);
1152-
return ret ?: trans_was_restarted(trans, restart_count);
1151+
return ret;
1152+
}
1153+
1154+
static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
1155+
{
1156+
u32 restart_count = trans->restart_count;
1157+
return check_i_sectors_notnested(trans, w) ?:
1158+
trans_was_restarted(trans, restart_count);
11531159
}
11541160

11551161
struct extent_end {
@@ -1533,7 +1539,7 @@ int bch2_check_extents(struct bch_fs *c)
15331539
check_extent(trans, &iter, k, &w, &s, &extent_ends) ?:
15341540
check_extent_overbig(trans, &iter, k);
15351541
})) ?:
1536-
check_i_sectors(trans, &w));
1542+
check_i_sectors_notnested(trans, &w));
15371543

15381544
bch2_disk_reservation_put(c, &res);
15391545
extent_ends_exit(&extent_ends);
@@ -1563,10 +1569,9 @@ int bch2_check_indirect_extents(struct bch_fs *c)
15631569
return ret;
15641570
}
15651571

1566-
static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
1572+
static int check_subdir_count_notnested(struct btree_trans *trans, struct inode_walker *w)
15671573
{
15681574
struct bch_fs *c = trans->c;
1569-
u32 restart_count = trans->restart_count;
15701575
int ret = 0;
15711576
s64 count2;
15721577

@@ -1598,7 +1603,14 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
15981603
}
15991604
fsck_err:
16001605
bch_err_fn(c, ret);
1601-
return ret ?: trans_was_restarted(trans, restart_count);
1606+
return ret;
1607+
}
1608+
1609+
static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
1610+
{
1611+
u32 restart_count = trans->restart_count;
1612+
return check_subdir_count_notnested(trans, w) ?:
1613+
trans_was_restarted(trans, restart_count);
16021614
}
16031615

16041616
static int check_dirent_inode_dirent(struct btree_trans *trans,
@@ -2003,7 +2015,8 @@ int bch2_check_dirents(struct bch_fs *c)
20032015
k,
20042016
NULL, NULL,
20052017
BCH_TRANS_COMMIT_no_enospc,
2006-
check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)));
2018+
check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)) ?:
2019+
check_subdir_count_notnested(trans, &dir));
20072020

20082021
snapshots_seen_exit(&s);
20092022
inode_walker_exit(&dir);

0 commit comments

Comments
 (0)