@@ -631,8 +631,7 @@ int bch2_btree_path_relock_intent(struct btree_trans *trans,
631631}
632632
633633__flatten
634- bool bch2_btree_path_relock_norestart (struct btree_trans * trans ,
635- struct btree_path * path , unsigned long trace_ip )
634+ bool bch2_btree_path_relock_norestart (struct btree_trans * trans , struct btree_path * path )
636635{
637636 struct get_locks_fail f ;
638637
@@ -642,7 +641,7 @@ bool bch2_btree_path_relock_norestart(struct btree_trans *trans,
642641int __bch2_btree_path_relock (struct btree_trans * trans ,
643642 struct btree_path * path , unsigned long trace_ip )
644643{
645- if (!bch2_btree_path_relock_norestart (trans , path , trace_ip )) {
644+ if (!bch2_btree_path_relock_norestart (trans , path )) {
646645 trace_and_count (trans -> c , trans_restart_relock_path , trans , trace_ip , path );
647646 return btree_trans_restart (trans , BCH_ERR_transaction_restart_relock_path );
648647 }
@@ -759,12 +758,39 @@ int bch2_trans_relock(struct btree_trans *trans)
759758 if (unlikely (trans -> restarted ))
760759 return - ((int ) trans -> restarted );
761760
762- trans_for_each_path (trans , path , i )
761+ trans_for_each_path (trans , path , i ) {
762+ struct get_locks_fail f ;
763+
763764 if (path -> should_be_locked &&
764- !bch2_btree_path_relock_norestart (trans , path , _RET_IP_ )) {
765- trace_and_count (trans -> c , trans_restart_relock , trans , _RET_IP_ , path );
765+ !btree_path_get_locks (trans , path , false, & f )) {
766+ if (trace_trans_restart_relock_enabled ()) {
767+ struct printbuf buf = PRINTBUF ;
768+
769+ bch2_bpos_to_text (& buf , path -> pos );
770+ prt_printf (& buf , " l=%u seq=%u node seq=" ,
771+ f .l , path -> l [f .l ].lock_seq );
772+ if (IS_ERR_OR_NULL (f .b )) {
773+ prt_str (& buf , bch2_err_str (PTR_ERR (f .b )));
774+ } else {
775+ prt_printf (& buf , "%u" , f .b -> c .lock .seq );
776+
777+ struct six_lock_count c =
778+ bch2_btree_node_lock_counts (trans , NULL , & f .b -> c , f .l );
779+ prt_printf (& buf , " self locked %u.%u.%u" , c .n [0 ], c .n [1 ], c .n [2 ]);
780+
781+ c = six_lock_counts (& f .b -> c .lock );
782+ prt_printf (& buf , " total locked %u.%u.%u" , c .n [0 ], c .n [1 ], c .n [2 ]);
783+ }
784+
785+ trace_trans_restart_relock (trans , _RET_IP_ , buf .buf );
786+ printbuf_exit (& buf );
787+ }
788+
789+ count_event (trans -> c , trans_restart_relock );
766790 return btree_trans_restart (trans , BCH_ERR_transaction_restart_relock );
767791 }
792+ }
793+
768794 return 0 ;
769795}
770796
@@ -778,7 +804,7 @@ int bch2_trans_relock_notrace(struct btree_trans *trans)
778804
779805 trans_for_each_path (trans , path , i )
780806 if (path -> should_be_locked &&
781- !bch2_btree_path_relock_norestart (trans , path , _RET_IP_ )) {
807+ !bch2_btree_path_relock_norestart (trans , path )) {
782808 return btree_trans_restart (trans , BCH_ERR_transaction_restart_relock );
783809 }
784810 return 0 ;
0 commit comments