@@ -75,13 +75,6 @@ static inline void mark_btree_node_locked_noreset(struct btree_path *path,
75
75
path -> nodes_locked |= (type + 1 ) << (level << 1 );
76
76
}
77
77
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
-
85
78
static inline void mark_btree_node_locked (struct btree_trans * trans ,
86
79
struct btree_path * path ,
87
80
unsigned level ,
@@ -124,19 +117,25 @@ static void btree_trans_lock_hold_time_update(struct btree_trans *trans,
124
117
125
118
/* unlock: */
126
119
120
+ void bch2_btree_node_unlock_write (struct btree_trans * ,
121
+ struct btree_path * , struct btree * );
122
+
127
123
static inline void btree_node_unlock (struct btree_trans * trans ,
128
124
struct btree_path * path , unsigned level )
129
125
{
130
126
int lock_type = btree_node_locked_type (path , level );
131
127
132
128
EBUG_ON (level >= BTREE_MAX_DEPTH );
133
- EBUG_ON (lock_type == BTREE_NODE_WRITE_LOCKED );
134
129
135
130
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
+ }
136
135
six_unlock_type (& path -> l [level ].b -> c .lock , lock_type );
137
136
btree_trans_lock_hold_time_update (trans , path , level );
137
+ mark_btree_node_locked_noreset (path , level , BTREE_NODE_UNLOCKED );
138
138
}
139
- mark_btree_node_unlocked (path , level );
140
139
}
141
140
142
141
static 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,
165
164
static inline void
166
165
__bch2_btree_node_unlock_write (struct btree_trans * trans , struct btree * b )
167
166
{
168
- struct btree_path * linked ;
169
- unsigned i ;
167
+ if (!b -> c .lock .write_lock_recurse ) {
168
+ struct btree_path * linked ;
169
+ unsigned i ;
170
170
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
+ }
173
174
174
175
six_unlock_write (& b -> c .lock );
175
176
}
@@ -186,9 +187,6 @@ bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_pat
186
187
__bch2_btree_node_unlock_write (trans , b );
187
188
}
188
189
189
- void bch2_btree_node_unlock_write (struct btree_trans * ,
190
- struct btree_path * , struct btree * );
191
-
192
190
int bch2_six_check_for_deadlock (struct six_lock * lock , void * p );
193
191
194
192
/* lock: */
0 commit comments