@@ -62,44 +62,34 @@ static void dlm_release_masters_list(struct dlm_ls *ls)
6262 write_unlock (& ls -> ls_masters_lock );
6363}
6464
65- static void dlm_create_root_list (struct dlm_ls * ls )
65+ static void dlm_create_root_list (struct dlm_ls * ls , struct list_head * root_list )
6666{
6767 struct rb_node * n ;
6868 struct dlm_rsb * r ;
6969 int i ;
7070
71- down_write (& ls -> ls_root_sem );
72- if (!list_empty (& ls -> ls_root_list )) {
73- log_error (ls , "root list not empty" );
74- goto out ;
75- }
76-
7771 for (i = 0 ; i < ls -> ls_rsbtbl_size ; i ++ ) {
7872 spin_lock_bh (& ls -> ls_rsbtbl [i ].lock );
7973 for (n = rb_first (& ls -> ls_rsbtbl [i ].keep ); n ; n = rb_next (n )) {
8074 r = rb_entry (n , struct dlm_rsb , res_hashnode );
81- list_add (& r -> res_root_list , & ls -> ls_root_list );
75+ list_add (& r -> res_root_list , root_list );
8276 dlm_hold_rsb (r );
8377 }
8478
8579 if (!RB_EMPTY_ROOT (& ls -> ls_rsbtbl [i ].toss ))
8680 log_error (ls , "%s toss not empty" , __func__ );
8781 spin_unlock_bh (& ls -> ls_rsbtbl [i ].lock );
8882 }
89- out :
90- up_write (& ls -> ls_root_sem );
9183}
9284
93- static void dlm_release_root_list (struct dlm_ls * ls )
85+ static void dlm_release_root_list (struct list_head * root_list )
9486{
9587 struct dlm_rsb * r , * safe ;
9688
97- down_write (& ls -> ls_root_sem );
98- list_for_each_entry_safe (r , safe , & ls -> ls_root_list , res_root_list ) {
89+ list_for_each_entry_safe (r , safe , root_list , res_root_list ) {
9990 list_del_init (& r -> res_root_list );
10091 dlm_put_rsb (r );
10192 }
102- up_write (& ls -> ls_root_sem );
10393}
10494
10595/* If the start for which we're re-enabling locking (seq) has been superseded
@@ -131,6 +121,7 @@ static int enable_locking(struct dlm_ls *ls, uint64_t seq)
131121
132122static int ls_recover (struct dlm_ls * ls , struct dlm_recover * rv )
133123{
124+ LIST_HEAD (root_list );
134125 unsigned long start ;
135126 int error , neg = 0 ;
136127
@@ -147,7 +138,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
147138 * routines.
148139 */
149140
150- dlm_create_root_list (ls );
141+ dlm_create_root_list (ls , & root_list );
151142
152143 /*
153144 * Add or remove nodes from the lockspace's ls_nodes list.
@@ -163,7 +154,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
163154 goto fail ;
164155 }
165156
166- dlm_recover_dir_nodeid (ls );
157+ dlm_recover_dir_nodeid (ls , & root_list );
167158
168159 /* Create a snapshot of all active rsbs were we are the master of.
169160 * During the barrier between dlm_recover_members_wait() and
@@ -179,7 +170,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
179170 error = dlm_create_masters_list (ls );
180171 if (error ) {
181172 log_rinfo (ls , "dlm_create_masters_list error %d" , error );
182- goto fail ;
173+ goto fail_root_list ;
183174 }
184175
185176 ls -> ls_recover_dir_sent_res = 0 ;
@@ -192,7 +183,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
192183 if (error ) {
193184 log_rinfo (ls , "dlm_recover_members_wait error %d" , error );
194185 dlm_release_masters_list (ls );
195- goto fail ;
186+ goto fail_root_list ;
196187 }
197188
198189 start = jiffies ;
@@ -206,7 +197,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
206197 if (error ) {
207198 log_rinfo (ls , "dlm_recover_directory error %d" , error );
208199 dlm_release_masters_list (ls );
209- goto fail ;
200+ goto fail_root_list ;
210201 }
211202
212203 dlm_set_recover_status (ls , DLM_RS_DIR );
@@ -215,7 +206,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
215206 if (error ) {
216207 log_rinfo (ls , "dlm_recover_directory_wait error %d" , error );
217208 dlm_release_masters_list (ls );
218- goto fail ;
209+ goto fail_root_list ;
219210 }
220211
221212 dlm_release_masters_list (ls );
@@ -233,43 +224,43 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
233224
234225 if (dlm_recovery_stopped (ls )) {
235226 error = - EINTR ;
236- goto fail ;
227+ goto fail_root_list ;
237228 }
238229
239230 if (neg || dlm_no_directory (ls )) {
240231 /*
241232 * Clear lkb's for departed nodes.
242233 */
243234
244- dlm_recover_purge (ls );
235+ dlm_recover_purge (ls , & root_list );
245236
246237 /*
247238 * Get new master nodeid's for rsb's that were mastered on
248239 * departed nodes.
249240 */
250241
251- error = dlm_recover_masters (ls , rv -> seq );
242+ error = dlm_recover_masters (ls , rv -> seq , & root_list );
252243 if (error ) {
253244 log_rinfo (ls , "dlm_recover_masters error %d" , error );
254- goto fail ;
245+ goto fail_root_list ;
255246 }
256247
257248 /*
258249 * Send our locks on remastered rsb's to the new masters.
259250 */
260251
261- error = dlm_recover_locks (ls , rv -> seq );
252+ error = dlm_recover_locks (ls , rv -> seq , & root_list );
262253 if (error ) {
263254 log_rinfo (ls , "dlm_recover_locks error %d" , error );
264- goto fail ;
255+ goto fail_root_list ;
265256 }
266257
267258 dlm_set_recover_status (ls , DLM_RS_LOCKS );
268259
269260 error = dlm_recover_locks_wait (ls , rv -> seq );
270261 if (error ) {
271262 log_rinfo (ls , "dlm_recover_locks_wait error %d" , error );
272- goto fail ;
263+ goto fail_root_list ;
273264 }
274265
275266 log_rinfo (ls , "dlm_recover_locks %u in" ,
@@ -281,7 +272,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
281272 * settings.
282273 */
283274
284- dlm_recover_rsbs (ls );
275+ dlm_recover_rsbs (ls , & root_list );
285276 } else {
286277 /*
287278 * Other lockspace members may be going through the "neg" steps
@@ -293,11 +284,11 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
293284 error = dlm_recover_locks_wait (ls , rv -> seq );
294285 if (error ) {
295286 log_rinfo (ls , "dlm_recover_locks_wait error %d" , error );
296- goto fail ;
287+ goto fail_root_list ;
297288 }
298289 }
299290
300- dlm_release_root_list (ls );
291+ dlm_release_root_list (& root_list );
301292
302293 /*
303294 * Purge directory-related requests that are saved in requestqueue.
@@ -346,8 +337,9 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
346337
347338 return 0 ;
348339
340+ fail_root_list :
341+ dlm_release_root_list (& root_list );
349342 fail :
350- dlm_release_root_list (ls );
351343 mutex_unlock (& ls -> ls_recoverd_active );
352344
353345 return error ;
0 commit comments