diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:19 -0500 |
commit | 2a86b3e74f12bcdd13ceb1bf333bc2d5f43b3c02 (patch) | |
tree | 142d8492bdeb66b6edfba7302ccc38dbd1e7227a /fs/dlm | |
parent | a1c36b166be76763cfab1a4308a00d6ffd8a2cc0 (diff) |
dlm: convert to idr_alloc()
Convert to the much saner new idr interface. Error return values from
recover_idr_add() mix -1 and -errno. The conversion doesn't change
that but it looks iffy.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/dlm')
-rw-r--r-- | fs/dlm/lock.c | 18 | ||||
-rw-r--r-- | fs/dlm/recover.c | 27 |
2 files changed, 19 insertions, 26 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index f7501651762d..1b1146670c4b 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -1183,7 +1183,7 @@ static void detach_lkb(struct dlm_lkb *lkb) | |||
1183 | static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) | 1183 | static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) |
1184 | { | 1184 | { |
1185 | struct dlm_lkb *lkb; | 1185 | struct dlm_lkb *lkb; |
1186 | int rv, id; | 1186 | int rv; |
1187 | 1187 | ||
1188 | lkb = dlm_allocate_lkb(ls); | 1188 | lkb = dlm_allocate_lkb(ls); |
1189 | if (!lkb) | 1189 | if (!lkb) |
@@ -1199,19 +1199,13 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) | |||
1199 | mutex_init(&lkb->lkb_cb_mutex); | 1199 | mutex_init(&lkb->lkb_cb_mutex); |
1200 | INIT_WORK(&lkb->lkb_cb_work, dlm_callback_work); | 1200 | INIT_WORK(&lkb->lkb_cb_work, dlm_callback_work); |
1201 | 1201 | ||
1202 | retry: | 1202 | idr_preload(GFP_NOFS); |
1203 | rv = idr_pre_get(&ls->ls_lkbidr, GFP_NOFS); | ||
1204 | if (!rv) | ||
1205 | return -ENOMEM; | ||
1206 | |||
1207 | spin_lock(&ls->ls_lkbidr_spin); | 1203 | spin_lock(&ls->ls_lkbidr_spin); |
1208 | rv = idr_get_new_above(&ls->ls_lkbidr, lkb, 1, &id); | 1204 | rv = idr_alloc(&ls->ls_lkbidr, lkb, 1, 0, GFP_NOWAIT); |
1209 | if (!rv) | 1205 | if (rv >= 0) |
1210 | lkb->lkb_id = id; | 1206 | lkb->lkb_id = rv; |
1211 | spin_unlock(&ls->ls_lkbidr_spin); | 1207 | spin_unlock(&ls->ls_lkbidr_spin); |
1212 | 1208 | idr_preload_end(); | |
1213 | if (rv == -EAGAIN) | ||
1214 | goto retry; | ||
1215 | 1209 | ||
1216 | if (rv < 0) { | 1210 | if (rv < 0) { |
1217 | log_error(ls, "create_lkb idr error %d", rv); | 1211 | log_error(ls, "create_lkb idr error %d", rv); |
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c index 236d1085d6a2..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) |