aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/inotify.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/inotify.c b/fs/inotify.c
index a8a714e48140..27ebcac5e07f 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -90,6 +90,7 @@ struct inotify_device {
90 unsigned int queue_size; /* size of the queue (bytes) */ 90 unsigned int queue_size; /* size of the queue (bytes) */
91 unsigned int event_count; /* number of pending events */ 91 unsigned int event_count; /* number of pending events */
92 unsigned int max_events; /* maximum number of events */ 92 unsigned int max_events; /* maximum number of events */
93 u32 last_wd; /* the last wd allocated */
93}; 94};
94 95
95/* 96/*
@@ -352,7 +353,7 @@ static int inotify_dev_get_wd(struct inotify_device *dev,
352 do { 353 do {
353 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL))) 354 if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
354 return -ENOSPC; 355 return -ENOSPC;
355 ret = idr_get_new(&dev->idr, watch, &watch->wd); 356 ret = idr_get_new_above(&dev->idr, watch, dev->last_wd, &watch->wd);
356 } while (ret == -EAGAIN); 357 } while (ret == -EAGAIN);
357 358
358 return ret; 359 return ret;
@@ -401,6 +402,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
401 return ERR_PTR(ret); 402 return ERR_PTR(ret);
402 } 403 }
403 404
405 dev->last_wd = ret;
404 watch->mask = mask; 406 watch->mask = mask;
405 atomic_set(&watch->count, 0); 407 atomic_set(&watch->count, 0);
406 INIT_LIST_HEAD(&watch->d_list); 408 INIT_LIST_HEAD(&watch->d_list);
@@ -899,6 +901,7 @@ asmlinkage long sys_inotify_init(void)
899 dev->queue_size = 0; 901 dev->queue_size = 0;
900 dev->max_events = inotify_max_queued_events; 902 dev->max_events = inotify_max_queued_events;
901 dev->user = user; 903 dev->user = user;
904 dev->last_wd = 0;
902 atomic_set(&dev->count, 0); 905 atomic_set(&dev->count, 0);
903 906
904 get_inotify_dev(dev); 907 get_inotify_dev(dev);