@@ -709,7 +709,6 @@ static noinline struct btree *bch2_btree_node_fill(struct btree_trans *trans,
709
709
struct bch_fs * c = trans -> c ;
710
710
struct btree_cache * bc = & c -> btree_cache ;
711
711
struct btree * b ;
712
- u32 seq ;
713
712
714
713
if (unlikely (level >= BTREE_MAX_DEPTH )) {
715
714
int ret = bch2_fs_topology_error (c , "attempting to get btree node at level %u, >= max depth %u" ,
@@ -775,34 +774,26 @@ static noinline struct btree *bch2_btree_node_fill(struct btree_trans *trans,
775
774
}
776
775
777
776
set_btree_node_read_in_flight (b );
778
-
779
777
six_unlock_write (& b -> c .lock );
780
- seq = six_lock_seq (& b -> c .lock );
781
- six_unlock_intent (& b -> c .lock );
782
778
783
- /* Unlock before doing IO: */
784
- if (path && sync )
785
- bch2_trans_unlock_noassert (trans );
786
-
787
- bch2_btree_node_read (trans , b , sync );
779
+ if (path ) {
780
+ u32 seq = six_lock_seq (& b -> c .lock );
788
781
789
- if (!sync )
790
- return NULL ;
782
+ /* Unlock before doing IO: */
783
+ six_unlock_intent (& b -> c .lock );
784
+ bch2_trans_unlock_noassert (trans );
791
785
792
- if (path ) {
793
- int ret = bch2_trans_relock (trans ) ?:
794
- bch2_btree_path_relock_intent (trans , path );
795
- if (ret ) {
796
- BUG_ON (!trans -> restarted );
797
- return ERR_PTR (ret );
798
- }
799
- }
786
+ bch2_btree_node_read (trans , b , sync );
800
787
801
- if (!six_relock_type ( & b -> c . lock , lock_type , seq )) {
802
- BUG_ON (! path ) ;
788
+ if (!sync )
789
+ return NULL ;
803
790
804
- trace_and_count (c , trans_restart_relock_after_fill , trans , _THIS_IP_ , path );
805
- return ERR_PTR (btree_trans_restart (trans , BCH_ERR_transaction_restart_relock_after_fill ));
791
+ if (!six_relock_type (& b -> c .lock , lock_type , seq ))
792
+ b = NULL ;
793
+ } else {
794
+ bch2_btree_node_read (trans , b , sync );
795
+ if (lock_type == SIX_LOCK_read )
796
+ six_lock_downgrade (& b -> c .lock );
806
797
}
807
798
808
799
return b ;
@@ -1135,18 +1126,19 @@ int bch2_btree_node_prefetch(struct btree_trans *trans,
1135
1126
{
1136
1127
struct bch_fs * c = trans -> c ;
1137
1128
struct btree_cache * bc = & c -> btree_cache ;
1138
- struct btree * b ;
1139
1129
1140
1130
BUG_ON (path && !btree_node_locked (path , level + 1 ));
1141
1131
BUG_ON (level >= BTREE_MAX_DEPTH );
1142
1132
1143
- b = btree_cache_find (bc , k );
1133
+ struct btree * b = btree_cache_find (bc , k );
1144
1134
if (b )
1145
1135
return 0 ;
1146
1136
1147
1137
b = bch2_btree_node_fill (trans , path , k , btree_id ,
1148
1138
level , SIX_LOCK_read , false);
1149
- return PTR_ERR_OR_ZERO (b );
1139
+ if (!IS_ERR_OR_NULL (b ))
1140
+ six_unlock_read (& b -> c .lock );
1141
+ return bch2_trans_relock (trans ) ?: PTR_ERR_OR_ZERO (b );
1150
1142
}
1151
1143
1152
1144
void bch2_btree_node_evict (struct btree_trans * trans , const struct bkey_i * k )
0 commit comments