ocfs2: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 28 Feb 2013 01:04:51 +0000 (17:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:19 +0000 (19:10 -0800)
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>
fs/ocfs2/cluster/tcp.c

index 0d2bf56..aa88bd8 100644 (file)
@@ -304,28 +304,22 @@ static u8 o2net_num_from_nn(struct o2net_node *nn)
 
 static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)
 {
-       int ret = 0;
-
-       do {
-               if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) {
-                       ret = -EAGAIN;
-                       break;
-               }
-               spin_lock(&nn->nn_lock);
-               ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id);
-               if (ret == 0)
-                       list_add_tail(&nsw->ns_node_item,
-                                     &nn->nn_status_list);
-               spin_unlock(&nn->nn_lock);
-       } while (ret == -EAGAIN);
+       int ret;
 
-       if (ret == 0)  {
-               init_waitqueue_head(&nsw->ns_wq);
-               nsw->ns_sys_status = O2NET_ERR_NONE;
-               nsw->ns_status = 0;
+       spin_lock(&nn->nn_lock);
+       ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC);
+       if (ret >= 0) {
+               nsw->ns_id = ret;
+               list_add_tail(&nsw->ns_node_item, &nn->nn_status_list);
        }
+       spin_unlock(&nn->nn_lock);
+       if (ret < 0)
+               return ret;
 
-       return ret;
+       init_waitqueue_head(&nsw->ns_wq);
+       nsw->ns_sys_status = O2NET_ERR_NONE;
+       nsw->ns_status = 0;
+       return 0;
 }
 
 static void o2net_complete_nsw_locked(struct o2net_node *nn,