]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/notify/inotify/inotify_user.c
inotify: convert to idr_alloc()
[karo-tx-linux.git] / fs / notify / inotify / inotify_user.c
index 07f7a92fe88e5cc69be0d8db0ce498a2d81aaf31..e0f7c1241a6adb60e03034bb118586407a24e37c 100644 (file)
@@ -364,22 +364,20 @@ static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
 {
        int ret;
 
-       do {
-               if (unlikely(!idr_pre_get(idr, GFP_KERNEL)))
-                       return -ENOMEM;
+       idr_preload(GFP_KERNEL);
+       spin_lock(idr_lock);
 
-               spin_lock(idr_lock);
-               ret = idr_get_new_above(idr, i_mark, *last_wd + 1,
-                                       &i_mark->wd);
+       ret = idr_alloc(idr, i_mark, *last_wd + 1, 0, GFP_NOWAIT);
+       if (ret >= 0) {
                /* we added the mark to the idr, take a reference */
-               if (!ret) {
-                       *last_wd = i_mark->wd;
-                       fsnotify_get_mark(&i_mark->fsn_mark);
-               }
-               spin_unlock(idr_lock);
-       } while (ret == -EAGAIN);
+               i_mark->wd = ret;
+               *last_wd = i_mark->wd;
+               fsnotify_get_mark(&i_mark->fsn_mark);
+       }
 
-       return ret;
+       spin_unlock(idr_lock);
+       idr_preload_end();
+       return ret < 0 ? ret : 0;
 }
 
 static struct inotify_inode_mark *inotify_idr_find_locked(struct fsnotify_group *group,