@@ -92,34 +92,32 @@ static int check_subvol(struct btree_trans *trans,
9292 }
9393
9494 struct bch_inode_unpacked inode ;
95- struct btree_iter inode_iter = {};
96- ret = bch2_inode_peek_nowarn (trans , & inode_iter , & inode ,
95+ ret = bch2_inode_find_by_inum_nowarn_trans (trans ,
9796 (subvol_inum ) { k .k -> p .offset , le64_to_cpu (subvol .v -> inode ) },
98- 0 );
99- bch2_trans_iter_exit (trans , & inode_iter );
100-
101- if (ret && !bch2_err_matches (ret , ENOENT ))
102- return ret ;
103-
104- if (fsck_err_on (ret ,
105- trans , subvol_to_missing_root ,
106- "subvolume %llu points to missing subvolume root %llu:%u" ,
107- k .k -> p .offset , le64_to_cpu (subvol .v -> inode ),
108- le32_to_cpu (subvol .v -> snapshot ))) {
109- ret = bch2_subvolume_delete (trans , iter -> pos .offset );
110- bch_err_msg (c , ret , "deleting subvolume %llu" , iter -> pos .offset );
111- return ret ?: - BCH_ERR_transaction_restart_nested ;
112- }
113-
114- if (fsck_err_on (inode .bi_subvol != subvol .k -> p .offset ,
115- trans , subvol_root_wrong_bi_subvol ,
116- "subvol root %llu:%u has wrong bi_subvol field: got %u, should be %llu" ,
117- inode .bi_inum , inode_iter .k .p .snapshot ,
118- inode .bi_subvol , subvol .k -> p .offset )) {
119- inode .bi_subvol = subvol .k -> p .offset ;
120- ret = __bch2_fsck_write_inode (trans , & inode , le32_to_cpu (subvol .v -> snapshot ));
121- if (ret )
97+ & inode );
98+ if (!ret ) {
99+ if (fsck_err_on (inode .bi_subvol != subvol .k -> p .offset ,
100+ trans , subvol_root_wrong_bi_subvol ,
101+ "subvol root %llu:%u has wrong bi_subvol field: got %u, should be %llu" ,
102+ inode .bi_inum , inode .bi_snapshot ,
103+ inode .bi_subvol , subvol .k -> p .offset )) {
104+ inode .bi_subvol = subvol .k -> p .offset ;
105+ ret = __bch2_fsck_write_inode (trans , & inode , le32_to_cpu (subvol .v -> snapshot ));
106+ if (ret )
107+ goto err ;
108+ }
109+ } else if (bch2_err_matches (ret , ENOENT )) {
110+ if (fsck_err (trans , subvol_to_missing_root ,
111+ "subvolume %llu points to missing subvolume root %llu:%u" ,
112+ k .k -> p .offset , le64_to_cpu (subvol .v -> inode ),
113+ le32_to_cpu (subvol .v -> snapshot ))) {
114+ ret = bch2_subvolume_delete (trans , iter -> pos .offset );
115+ bch_err_msg (c , ret , "deleting subvolume %llu" , iter -> pos .offset );
116+ ret = ret ?: - BCH_ERR_transaction_restart_nested ;
122117 goto err ;
118+ }
119+ } else {
120+ goto err ;
123121 }
124122
125123 if (!BCH_SUBVOLUME_SNAP (subvol .v )) {
@@ -137,7 +135,7 @@ static int check_subvol(struct btree_trans *trans,
137135 "%s: snapshot tree %u not found" , __func__ , snapshot_tree );
138136
139137 if (ret )
140- return ret ;
138+ goto err ;
141139
142140 if (fsck_err_on (le32_to_cpu (st .master_subvol ) != subvol .k -> p .offset ,
143141 trans , subvol_not_master_and_not_snapshot ,
@@ -147,7 +145,7 @@ static int check_subvol(struct btree_trans *trans,
147145 bch2_bkey_make_mut_typed (trans , iter , & subvol .s_c , 0 , subvolume );
148146 ret = PTR_ERR_OR_ZERO (s );
149147 if (ret )
150- return ret ;
148+ goto err ;
151149
152150 SET_BCH_SUBVOLUME_SNAP (& s -> v , true);
153151 }
0 commit comments