diff options
author | John McCutchan <ttb@tentacle.dhs.org> | 2005-09-06 18:16:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:19 -0400 |
commit | 820249bafe441dce5336ad544a5e709df42fceb5 (patch) | |
tree | 01d296cba9583c05a88ea19e68f40f3817829a39 | |
parent | 19306059cd7fedaf96b4b0260a9a8a45e513c857 (diff) |
[PATCH] inotify speedup
Bypass an inotify-related fastpath spinlock and several function calls on
systems which have no inotify watches registered.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/inotify.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index 2e4e2a57708c..2fd97ef547ff 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <asm/ioctls.h> | 37 | #include <asm/ioctls.h> |
38 | 38 | ||
39 | static atomic_t inotify_cookie; | 39 | static atomic_t inotify_cookie; |
40 | static atomic_t inotify_watches; | ||
40 | 41 | ||
41 | static kmem_cache_t *watch_cachep; | 42 | static kmem_cache_t *watch_cachep; |
42 | static kmem_cache_t *event_cachep; | 43 | static kmem_cache_t *event_cachep; |
@@ -422,6 +423,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev, | |||
422 | get_inotify_watch(watch); | 423 | get_inotify_watch(watch); |
423 | 424 | ||
424 | atomic_inc(&dev->user->inotify_watches); | 425 | atomic_inc(&dev->user->inotify_watches); |
426 | atomic_inc(&inotify_watches); | ||
425 | 427 | ||
426 | return watch; | 428 | return watch; |
427 | } | 429 | } |
@@ -454,6 +456,7 @@ static void remove_watch_no_event(struct inotify_watch *watch, | |||
454 | list_del(&watch->d_list); | 456 | list_del(&watch->d_list); |
455 | 457 | ||
456 | atomic_dec(&dev->user->inotify_watches); | 458 | atomic_dec(&dev->user->inotify_watches); |
459 | atomic_dec(&inotify_watches); | ||
457 | idr_remove(&dev->idr, watch->wd); | 460 | idr_remove(&dev->idr, watch->wd); |
458 | put_inotify_watch(watch); | 461 | put_inotify_watch(watch); |
459 | } | 462 | } |
@@ -532,6 +535,9 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask, | |||
532 | struct dentry *parent; | 535 | struct dentry *parent; |
533 | struct inode *inode; | 536 | struct inode *inode; |
534 | 537 | ||
538 | if (!atomic_read (&inotify_watches)) | ||
539 | return; | ||
540 | |||
535 | spin_lock(&dentry->d_lock); | 541 | spin_lock(&dentry->d_lock); |
536 | parent = dentry->d_parent; | 542 | parent = dentry->d_parent; |
537 | inode = parent->d_inode; | 543 | inode = parent->d_inode; |
@@ -1043,6 +1049,7 @@ static int __init inotify_setup(void) | |||
1043 | inotify_max_user_watches = 8192; | 1049 | inotify_max_user_watches = 8192; |
1044 | 1050 | ||
1045 | atomic_set(&inotify_cookie, 0); | 1051 | atomic_set(&inotify_cookie, 0); |
1052 | atomic_set(&inotify_watches, 0); | ||
1046 | 1053 | ||
1047 | watch_cachep = kmem_cache_create("inotify_watch_cache", | 1054 | watch_cachep = kmem_cache_create("inotify_watch_cache", |
1048 | sizeof(struct inotify_watch), | 1055 | sizeof(struct inotify_watch), |