@@ -75,13 +75,6 @@ static inline void mark_btree_node_locked_noreset(struct btree_path *path,
7575 path -> nodes_locked |= (type + 1 ) << (level << 1 );
7676}
7777
78- static inline void mark_btree_node_unlocked (struct btree_path * path ,
79- unsigned level )
80- {
81- EBUG_ON (btree_node_write_locked (path , level ));
82- mark_btree_node_locked_noreset (path , level , BTREE_NODE_UNLOCKED );
83- }
84-
8578static inline void mark_btree_node_locked (struct btree_trans * trans ,
8679 struct btree_path * path ,
8780 unsigned level ,
@@ -124,19 +117,25 @@ static void btree_trans_lock_hold_time_update(struct btree_trans *trans,
124117
125118/* unlock: */
126119
120+ void bch2_btree_node_unlock_write (struct btree_trans * ,
121+ struct btree_path * , struct btree * );
122+
127123static inline void btree_node_unlock (struct btree_trans * trans ,
128124 struct btree_path * path , unsigned level )
129125{
130126 int lock_type = btree_node_locked_type (path , level );
131127
132128 EBUG_ON (level >= BTREE_MAX_DEPTH );
133- EBUG_ON (lock_type == BTREE_NODE_WRITE_LOCKED );
134129
135130 if (lock_type != BTREE_NODE_UNLOCKED ) {
131+ if (unlikely (lock_type == BTREE_NODE_WRITE_LOCKED )) {
132+ bch2_btree_node_unlock_write (trans , path , path -> l [level ].b );
133+ lock_type = BTREE_NODE_INTENT_LOCKED ;
134+ }
136135 six_unlock_type (& path -> l [level ].b -> c .lock , lock_type );
137136 btree_trans_lock_hold_time_update (trans , path , level );
137+ mark_btree_node_locked_noreset (path , level , BTREE_NODE_UNLOCKED );
138138 }
139- mark_btree_node_unlocked (path , level );
140139}
141140
142141static inline int btree_path_lowest_level_locked (struct btree_path * path )
@@ -165,11 +164,13 @@ static inline void __bch2_btree_path_unlock(struct btree_trans *trans,
165164static inline void
166165__bch2_btree_node_unlock_write (struct btree_trans * trans , struct btree * b )
167166{
168- struct btree_path * linked ;
169- unsigned i ;
167+ if (!b -> c .lock .write_lock_recurse ) {
168+ struct btree_path * linked ;
169+ unsigned i ;
170170
171- trans_for_each_path_with_node (trans , b , linked , i )
172- linked -> l [b -> c .level ].lock_seq ++ ;
171+ trans_for_each_path_with_node (trans , b , linked , i )
172+ linked -> l [b -> c .level ].lock_seq ++ ;
173+ }
173174
174175 six_unlock_write (& b -> c .lock );
175176}
@@ -186,9 +187,6 @@ bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_pat
186187 __bch2_btree_node_unlock_write (trans , b );
187188}
188189
189- void bch2_btree_node_unlock_write (struct btree_trans * ,
190- struct btree_path * , struct btree * );
191-
192190int bch2_six_check_for_deadlock (struct six_lock * lock , void * p );
193191
194192/* lock: */
0 commit comments