@@ -175,10 +175,11 @@ static int set_node_max(struct bch_fs *c, struct btree *b, struct bpos new_max)
175175 return 0 ;
176176}
177177
178- static int btree_check_node_boundaries (struct bch_fs * c , struct btree * b ,
178+ static int btree_check_node_boundaries (struct btree_trans * trans , struct btree * b ,
179179 struct btree * prev , struct btree * cur ,
180180 struct bpos * pulled_from_scan )
181181{
182+ struct bch_fs * c = trans -> c ;
182183 struct bpos expected_start = !prev
183184 ? b -> data -> min_key
184185 : bpos_successor (prev -> key .k .p );
@@ -216,29 +217,29 @@ static int btree_check_node_boundaries(struct bch_fs *c, struct btree *b,
216217 * pulled_from_scan = cur -> data -> min_key ;
217218 ret = DID_FILL_FROM_SCAN ;
218219 } else {
219- if (mustfix_fsck_err (c , btree_node_topology_bad_min_key ,
220+ if (mustfix_fsck_err (trans , btree_node_topology_bad_min_key ,
220221 "btree node with incorrect min_key%s" , buf .buf ))
221222 ret = set_node_min (c , cur , expected_start );
222223 }
223224 } else { /* overlap */
224225 if (prev && BTREE_NODE_SEQ (cur -> data ) > BTREE_NODE_SEQ (prev -> data )) { /* cur overwrites prev */
225226 if (bpos_ge (prev -> data -> min_key , cur -> data -> min_key )) { /* fully? */
226- if (mustfix_fsck_err (c , btree_node_topology_overwritten_by_next_node ,
227+ if (mustfix_fsck_err (trans , btree_node_topology_overwritten_by_next_node ,
227228 "btree node overwritten by next node%s" , buf .buf ))
228229 ret = DROP_PREV_NODE ;
229230 } else {
230- if (mustfix_fsck_err (c , btree_node_topology_bad_max_key ,
231+ if (mustfix_fsck_err (trans , btree_node_topology_bad_max_key ,
231232 "btree node with incorrect max_key%s" , buf .buf ))
232233 ret = set_node_max (c , prev ,
233234 bpos_predecessor (cur -> data -> min_key ));
234235 }
235236 } else {
236237 if (bpos_ge (expected_start , cur -> data -> max_key )) { /* fully? */
237- if (mustfix_fsck_err (c , btree_node_topology_overwritten_by_prev_node ,
238+ if (mustfix_fsck_err (trans , btree_node_topology_overwritten_by_prev_node ,
238239 "btree node overwritten by prev node%s" , buf .buf ))
239240 ret = DROP_THIS_NODE ;
240241 } else {
241- if (mustfix_fsck_err (c , btree_node_topology_bad_min_key ,
242+ if (mustfix_fsck_err (trans , btree_node_topology_bad_min_key ,
242243 "btree node with incorrect min_key%s" , buf .buf ))
243244 ret = set_node_min (c , cur , expected_start );
244245 }
@@ -250,9 +251,10 @@ static int btree_check_node_boundaries(struct bch_fs *c, struct btree *b,
250251 return ret ;
251252}
252253
253- static int btree_repair_node_end (struct bch_fs * c , struct btree * b ,
254+ static int btree_repair_node_end (struct btree_trans * trans , struct btree * b ,
254255 struct btree * child , struct bpos * pulled_from_scan )
255256{
257+ struct bch_fs * c = trans -> c ;
256258 struct printbuf buf = PRINTBUF ;
257259 int ret = 0 ;
258260
@@ -266,7 +268,7 @@ static int btree_repair_node_end(struct bch_fs *c, struct btree *b,
266268 prt_str (& buf , "\n child: " );
267269 bch2_bkey_val_to_text (& buf , c , bkey_i_to_s_c (& child -> key ));
268270
269- if (mustfix_fsck_err (c , btree_node_topology_bad_max_key ,
271+ if (mustfix_fsck_err (trans , btree_node_topology_bad_max_key ,
270272 "btree node with incorrect max_key%s" , buf .buf )) {
271273 if (b -> c .level == 1 &&
272274 bpos_lt (* pulled_from_scan , b -> key .k .p )) {
@@ -325,8 +327,8 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
325327 printbuf_reset (& buf );
326328 bch2_bkey_val_to_text (& buf , c , bkey_i_to_s_c (cur_k .k ));
327329
328- if (mustfix_fsck_err_on (bch2_err_matches (ret , EIO ), c ,
329- btree_node_unreadable ,
330+ if (mustfix_fsck_err_on (bch2_err_matches (ret , EIO ),
331+ trans , btree_node_unreadable ,
330332 "Topology repair: unreadable btree node at btree %s level %u:\n"
331333 " %s" ,
332334 bch2_btree_id_str (b -> c .btree_id ),
@@ -363,7 +365,7 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
363365 continue ;
364366 }
365367
366- ret = btree_check_node_boundaries (c , b , prev , cur , pulled_from_scan );
368+ ret = btree_check_node_boundaries (trans , b , prev , cur , pulled_from_scan );
367369 if (ret == DID_FILL_FROM_SCAN ) {
368370 new_pass = true;
369371 ret = 0 ;
@@ -404,7 +406,7 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
404406
405407 if (!ret && !IS_ERR_OR_NULL (prev )) {
406408 BUG_ON (cur );
407- ret = btree_repair_node_end (c , b , prev , pulled_from_scan );
409+ ret = btree_repair_node_end (trans , b , prev , pulled_from_scan );
408410 if (ret == DID_FILL_FROM_SCAN ) {
409411 new_pass = true;
410412 ret = 0 ;
@@ -462,8 +464,8 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
462464 printbuf_reset (& buf );
463465 bch2_bkey_val_to_text (& buf , c , bkey_i_to_s_c (& b -> key ));
464466
465- if (mustfix_fsck_err_on (!have_child , c ,
466- btree_node_topology_interior_node_empty ,
467+ if (mustfix_fsck_err_on (!have_child ,
468+ trans , btree_node_topology_interior_node_empty ,
467469 "empty interior btree node at btree %s level %u\n"
468470 " %s" ,
469471 bch2_btree_id_str (b -> c .btree_id ),
@@ -510,7 +512,7 @@ int bch2_check_topology(struct bch_fs *c)
510512 r -> error = 0 ;
511513
512514 if (!bch2_btree_has_scanned_nodes (c , i )) {
513- mustfix_fsck_err (c , btree_root_unreadable_and_scan_found_nothing ,
515+ mustfix_fsck_err (trans , btree_root_unreadable_and_scan_found_nothing ,
514516 "no nodes found for btree %s, continue?" , bch2_btree_id_str (i ));
515517 bch2_btree_root_alloc_fake_trans (trans , i , 0 );
516518 } else {
@@ -585,16 +587,16 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
585587 k .k -> version .lo > atomic64_read (& c -> journal .seq ));
586588
587589 if (fsck_err_on (btree_id != BTREE_ID_accounting &&
588- k .k -> version .lo > atomic64_read (& c -> key_version ), c ,
589- bkey_version_in_future ,
590+ k .k -> version .lo > atomic64_read (& c -> key_version ),
591+ trans , bkey_version_in_future ,
590592 "key version number higher than recorded %llu\n %s" ,
591593 atomic64_read (& c -> key_version ),
592594 (bch2_bkey_val_to_text (& buf , c , k ), buf .buf )))
593595 atomic64_set (& c -> key_version , k .k -> version .lo );
594596 }
595597
596598 if (mustfix_fsck_err_on (level && !bch2_dev_btree_bitmap_marked (c , k ),
597- c , btree_bitmap_not_marked ,
599+ trans , btree_bitmap_not_marked ,
598600 "btree ptr not marked in member info btree allocated bitmap\n %s" ,
599601 (printbuf_reset (& buf ),
600602 bch2_bkey_val_to_text (& buf , c , k ),
@@ -710,7 +712,7 @@ static int bch2_gc_btrees(struct bch_fs *c)
710712 ret = bch2_gc_btree (trans , btree , true);
711713
712714 if (mustfix_fsck_err_on (bch2_err_matches (ret , EIO ),
713- c , btree_node_read_error ,
715+ trans , btree_node_read_error ,
714716 "btree node read error for %s" ,
715717 bch2_btree_id_str (btree )))
716718 ret = bch2_run_explicit_recovery_pass (c , BCH_RECOVERY_PASS_check_topology );
@@ -816,8 +818,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
816818
817819 gc .fragmentation_lru = alloc_lru_idx_fragmentation (gc , ca );
818820
819- if (fsck_err_on (new .data_type != gc .data_type , c ,
820- alloc_key_data_type_wrong ,
821+ if (fsck_err_on (new .data_type != gc .data_type ,
822+ trans , alloc_key_data_type_wrong ,
821823 "bucket %llu:%llu gen %u has wrong data_type"
822824 ": got %s, should be %s" ,
823825 iter -> pos .inode , iter -> pos .offset ,
@@ -827,7 +829,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
827829 new .data_type = gc .data_type ;
828830
829831#define copy_bucket_field (_errtype , _f ) \
830- if (fsck_err_on(new._f != gc._f, c, _errtype, \
832+ if (fsck_err_on(new._f != gc._f, \
833+ trans, _errtype, \
831834 "bucket %llu:%llu gen %u data type %s has wrong " #_f \
832835 ": got %llu, should be %llu", \
833836 iter->pos.inode, iter->pos.offset, \
@@ -939,8 +942,8 @@ static int bch2_gc_write_reflink_key(struct btree_trans *trans,
939942 return - EINVAL ;
940943 }
941944
942- if (fsck_err_on (r -> refcount != le64_to_cpu (* refcount ), c ,
943- reflink_v_refcount_wrong ,
945+ if (fsck_err_on (r -> refcount != le64_to_cpu (* refcount ),
946+ trans , reflink_v_refcount_wrong ,
944947 "reflink key has wrong refcount:\n"
945948 " %s\n"
946949 " should be %u" ,
@@ -1038,7 +1041,8 @@ static int bch2_gc_write_stripes_key(struct btree_trans *trans,
10381041 if (bad )
10391042 bch2_bkey_val_to_text (& buf , c , k );
10401043
1041- if (fsck_err_on (bad , c , stripe_sector_count_wrong ,
1044+ if (fsck_err_on (bad ,
1045+ trans , stripe_sector_count_wrong ,
10421046 "%s" , buf .buf )) {
10431047 struct bkey_i_stripe * new ;
10441048
0 commit comments