Commit 6b207ba3ebe7428a18878c58130e13a3e3bccef9
Committed by
Linus Torvalds
1 parent
4542da631a
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ocfs2: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Mark Fasheh <mfasheh@suse.com> Acked-by: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 13 additions and 19 deletions Side-by-side Diff
fs/ocfs2/cluster/tcp.c
... | ... | @@ -304,28 +304,22 @@ |
304 | 304 | |
305 | 305 | static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) |
306 | 306 | { |
307 | - int ret = 0; | |
307 | + int ret; | |
308 | 308 | |
309 | - do { | |
310 | - if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) { | |
311 | - ret = -EAGAIN; | |
312 | - break; | |
313 | - } | |
314 | - spin_lock(&nn->nn_lock); | |
315 | - ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id); | |
316 | - if (ret == 0) | |
317 | - list_add_tail(&nsw->ns_node_item, | |
318 | - &nn->nn_status_list); | |
319 | - spin_unlock(&nn->nn_lock); | |
320 | - } while (ret == -EAGAIN); | |
321 | - | |
322 | - if (ret == 0) { | |
323 | - init_waitqueue_head(&nsw->ns_wq); | |
324 | - nsw->ns_sys_status = O2NET_ERR_NONE; | |
325 | - nsw->ns_status = 0; | |
309 | + spin_lock(&nn->nn_lock); | |
310 | + ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC); | |
311 | + if (ret >= 0) { | |
312 | + nsw->ns_id = ret; | |
313 | + list_add_tail(&nsw->ns_node_item, &nn->nn_status_list); | |
326 | 314 | } |
315 | + spin_unlock(&nn->nn_lock); | |
316 | + if (ret < 0) | |
317 | + return ret; | |
327 | 318 | |
328 | - return ret; | |
319 | + init_waitqueue_head(&nsw->ns_wq); | |
320 | + nsw->ns_sys_status = O2NET_ERR_NONE; | |
321 | + nsw->ns_status = 0; | |
322 | + return 0; | |
329 | 323 | } |
330 | 324 | |
331 | 325 | static void o2net_complete_nsw_locked(struct o2net_node *nn, |