diff options
Diffstat (limited to 'fs/dlm/recover.c')
-rw-r--r-- | fs/dlm/recover.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c index aedea28a86a1..a6bc63f6e31b 100644 --- a/fs/dlm/recover.c +++ b/fs/dlm/recover.c | |||
@@ -305,27 +305,26 @@ static int recover_idr_empty(struct dlm_ls *ls) | |||
305 | static int recover_idr_add(struct dlm_rsb *r) | 305 | static int recover_idr_add(struct dlm_rsb *r) |
306 | { | 306 | { |
307 | struct dlm_ls *ls = r->res_ls; | 307 | struct dlm_ls *ls = r->res_ls; |
308 | int rv, id; | 308 | int rv; |
309 | |||
310 | rv = idr_pre_get(&ls->ls_recover_idr, GFP_NOFS); | ||
311 | if (!rv) | ||
312 | return -ENOMEM; | ||
313 | 309 | ||
310 | idr_preload(GFP_NOFS); | ||
314 | spin_lock(&ls->ls_recover_idr_lock); | 311 | spin_lock(&ls->ls_recover_idr_lock); |
315 | if (r->res_id) { | 312 | if (r->res_id) { |
316 | spin_unlock(&ls->ls_recover_idr_lock); | 313 | rv = -1; |
317 | return -1; | 314 | goto out_unlock; |
318 | } | ||
319 | rv = idr_get_new_above(&ls->ls_recover_idr, r, 1, &id); | ||
320 | if (rv) { | ||
321 | spin_unlock(&ls->ls_recover_idr_lock); | ||
322 | return rv; | ||
323 | } | 315 | } |
324 | r->res_id = id; | 316 | rv = idr_alloc(&ls->ls_recover_idr, r, 1, 0, GFP_NOWAIT); |
317 | if (rv < 0) | ||
318 | goto out_unlock; | ||
319 | |||
320 | r->res_id = rv; | ||
325 | ls->ls_recover_list_count++; | 321 | ls->ls_recover_list_count++; |
326 | dlm_hold_rsb(r); | 322 | dlm_hold_rsb(r); |
323 | rv = 0; | ||
324 | out_unlock: | ||
327 | spin_unlock(&ls->ls_recover_idr_lock); | 325 | spin_unlock(&ls->ls_recover_idr_lock); |
328 | return 0; | 326 | idr_preload_end(); |
327 | return rv; | ||
329 | } | 328 | } |
330 | 329 | ||
331 | static void recover_idr_del(struct dlm_rsb *r) | 330 | static void recover_idr_del(struct dlm_rsb *r) |
@@ -351,24 +350,21 @@ static struct dlm_rsb *recover_idr_find(struct dlm_ls *ls, uint64_t id) | |||
351 | return r; | 350 | return r; |
352 | } | 351 | } |
353 | 352 | ||
354 | static int recover_idr_clear_rsb(int id, void *p, void *data) | 353 | static void recover_idr_clear(struct dlm_ls *ls) |
355 | { | 354 | { |
356 | struct dlm_ls *ls = data; | 355 | struct dlm_rsb *r; |
357 | struct dlm_rsb *r = p; | 356 | int id; |
358 | 357 | ||
359 | r->res_id = 0; | 358 | spin_lock(&ls->ls_recover_idr_lock); |
360 | r->res_recover_locks_count = 0; | ||
361 | ls->ls_recover_list_count--; | ||
362 | 359 | ||
363 | dlm_put_rsb(r); | 360 | idr_for_each_entry(&ls->ls_recover_idr, r, id) { |
364 | return 0; | 361 | idr_remove(&ls->ls_recover_idr, id); |
365 | } | 362 | r->res_id = 0; |
363 | r->res_recover_locks_count = 0; | ||
364 | ls->ls_recover_list_count--; | ||
366 | 365 | ||
367 | static void recover_idr_clear(struct dlm_ls *ls) | 366 | dlm_put_rsb(r); |
368 | { | 367 | } |
369 | spin_lock(&ls->ls_recover_idr_lock); | ||
370 | idr_for_each(&ls->ls_recover_idr, recover_idr_clear_rsb, ls); | ||
371 | idr_remove_all(&ls->ls_recover_idr); | ||
372 | 368 | ||
373 | if (ls->ls_recover_list_count != 0) { | 369 | if (ls->ls_recover_list_count != 0) { |
374 | log_error(ls, "warning: recover_list_count %d", | 370 | log_error(ls, "warning: recover_list_count %d", |