diff options
author | Eric Paris <eparis@redhat.com> | 2009-07-15 15:49:52 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2009-07-21 15:26:27 -0400 |
commit | f44aebcc566d1d6275f7191867b9633dc11de2ee (patch) | |
tree | a5faaf5ca8e1360f359ee22ad29582992596c3e6 | |
parent | c05594b62125c528d93af3a78229793aae36df7f (diff) |
inotify: use GFP_NOFS under potential memory pressure
inotify can have a watchs removed under filesystem reclaim.
=================================
[ INFO: inconsistent lock state ]
2.6.31-rc2 #16
---------------------------------
inconsistent {IN-RECLAIM_FS-W} -> {RECLAIM_FS-ON-W} usage.
khubd/217 [HC0[0]:SC0[0]:HE1:SE1] takes:
(iprune_mutex){+.+.?.}, at: [<c10ba899>] invalidate_inodes+0x20/0xe3
{IN-RECLAIM_FS-W} state was registered at:
[<c10536ab>] __lock_acquire+0x2c9/0xac4
[<c1053f45>] lock_acquire+0x9f/0xc2
[<c1308872>] __mutex_lock_common+0x2d/0x323
[<c1308c00>] mutex_lock_nested+0x2e/0x36
[<c10ba6ff>] shrink_icache_memory+0x38/0x1b2
[<c108bfb6>] shrink_slab+0xe2/0x13c
[<c108c3e1>] kswapd+0x3d1/0x55d
[<c10449b5>] kthread+0x66/0x6b
[<c1003fdf>] kernel_thread_helper+0x7/0x10
[<ffffffff>] 0xffffffff
Two things are needed to fix this. First we need a method to tell
fsnotify_create_event() to use GFP_NOFS and second we need to stop using
one global IN_IGNORED event and allocate them one at a time. This solves
current issues with multiple IN_IGNORED on a queue having tail drop
problems and simplifies the allocations since we don't have to worry about
two tasks opperating on the IGNORED event concurrently.
Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r-- | fs/notify/fsnotify.c | 4 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 18 | ||||
-rw-r--r-- | fs/notify/notification.c | 9 | ||||
-rw-r--r-- | include/linux/fsnotify_backend.h | 2 |
4 files changed, 21 insertions, 12 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index ec2f7bd76818..037e878e03fc 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -159,7 +159,9 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const | |||
159 | if (!group->ops->should_send_event(group, to_tell, mask)) | 159 | if (!group->ops->should_send_event(group, to_tell, mask)) |
160 | continue; | 160 | continue; |
161 | if (!event) { | 161 | if (!event) { |
162 | event = fsnotify_create_event(to_tell, mask, data, data_is, file_name, cookie); | 162 | event = fsnotify_create_event(to_tell, mask, data, |
163 | data_is, file_name, cookie, | ||
164 | GFP_KERNEL); | ||
163 | /* shit, we OOM'd and now we can't tell, maybe | 165 | /* shit, we OOM'd and now we can't tell, maybe |
164 | * someday someone else will want to do something | 166 | * someday someone else will want to do something |
165 | * here */ | 167 | * here */ |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 726118a5845b..f30d9bbc2e1b 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -57,7 +57,6 @@ int inotify_max_user_watches __read_mostly; | |||
57 | 57 | ||
58 | static struct kmem_cache *inotify_inode_mark_cachep __read_mostly; | 58 | static struct kmem_cache *inotify_inode_mark_cachep __read_mostly; |
59 | struct kmem_cache *event_priv_cachep __read_mostly; | 59 | struct kmem_cache *event_priv_cachep __read_mostly; |
60 | static struct fsnotify_event *inotify_ignored_event; | ||
61 | 60 | ||
62 | /* | 61 | /* |
63 | * When inotify registers a new group it increments this and uses that | 62 | * When inotify registers a new group it increments this and uses that |
@@ -384,12 +383,19 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry, | |||
384 | struct fsnotify_group *group) | 383 | struct fsnotify_group *group) |
385 | { | 384 | { |
386 | struct inotify_inode_mark_entry *ientry; | 385 | struct inotify_inode_mark_entry *ientry; |
386 | struct fsnotify_event *ignored_event; | ||
387 | struct inotify_event_private_data *event_priv; | 387 | struct inotify_event_private_data *event_priv; |
388 | struct fsnotify_event_private_data *fsn_event_priv; | 388 | struct fsnotify_event_private_data *fsn_event_priv; |
389 | 389 | ||
390 | ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL, | ||
391 | FSNOTIFY_EVENT_NONE, NULL, 0, | ||
392 | GFP_NOFS); | ||
393 | if (!ignored_event) | ||
394 | return; | ||
395 | |||
390 | ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry); | 396 | ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry); |
391 | 397 | ||
392 | event_priv = kmem_cache_alloc(event_priv_cachep, GFP_KERNEL); | 398 | event_priv = kmem_cache_alloc(event_priv_cachep, GFP_NOFS); |
393 | if (unlikely(!event_priv)) | 399 | if (unlikely(!event_priv)) |
394 | goto skip_send_ignore; | 400 | goto skip_send_ignore; |
395 | 401 | ||
@@ -398,7 +404,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry, | |||
398 | fsn_event_priv->group = group; | 404 | fsn_event_priv->group = group; |
399 | event_priv->wd = ientry->wd; | 405 | event_priv->wd = ientry->wd; |
400 | 406 | ||
401 | fsnotify_add_notify_event(group, inotify_ignored_event, fsn_event_priv); | 407 | fsnotify_add_notify_event(group, ignored_event, fsn_event_priv); |
402 | 408 | ||
403 | /* did the private data get added? */ | 409 | /* did the private data get added? */ |
404 | if (list_empty(&fsn_event_priv->event_list)) | 410 | if (list_empty(&fsn_event_priv->event_list)) |
@@ -406,6 +412,9 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry, | |||
406 | 412 | ||
407 | skip_send_ignore: | 413 | skip_send_ignore: |
408 | 414 | ||
415 | /* matches the reference taken when the event was created */ | ||
416 | fsnotify_put_event(ignored_event); | ||
417 | |||
409 | /* remove this entry from the idr */ | 418 | /* remove this entry from the idr */ |
410 | inotify_remove_from_idr(group, ientry); | 419 | inotify_remove_from_idr(group, ientry); |
411 | 420 | ||
@@ -748,9 +757,6 @@ static int __init inotify_user_setup(void) | |||
748 | 757 | ||
749 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC); | 758 | inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC); |
750 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); | 759 | event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); |
751 | inotify_ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL, FSNOTIFY_EVENT_NONE, NULL, 0); | ||
752 | if (!inotify_ignored_event) | ||
753 | panic("unable to allocate the inotify ignored event\n"); | ||
754 | 760 | ||
755 | inotify_max_queued_events = 16384; | 761 | inotify_max_queued_events = 16384; |
756 | inotify_max_user_instances = 128; | 762 | inotify_max_user_instances = 128; |
diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 2b20feaf263a..521368574e97 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c | |||
@@ -153,7 +153,7 @@ static bool event_compare(struct fsnotify_event *old, struct fsnotify_event *new | |||
153 | return true; | 153 | return true; |
154 | break; | 154 | break; |
155 | case (FSNOTIFY_EVENT_NONE): | 155 | case (FSNOTIFY_EVENT_NONE): |
156 | return true; | 156 | return false; |
157 | }; | 157 | }; |
158 | } | 158 | } |
159 | return false; | 159 | return false; |
@@ -345,18 +345,19 @@ static void initialize_event(struct fsnotify_event *event) | |||
345 | * @name the filename, if available | 345 | * @name the filename, if available |
346 | */ | 346 | */ |
347 | struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, void *data, | 347 | struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, void *data, |
348 | int data_type, const char *name, u32 cookie) | 348 | int data_type, const char *name, u32 cookie, |
349 | gfp_t gfp) | ||
349 | { | 350 | { |
350 | struct fsnotify_event *event; | 351 | struct fsnotify_event *event; |
351 | 352 | ||
352 | event = kmem_cache_alloc(fsnotify_event_cachep, GFP_KERNEL); | 353 | event = kmem_cache_alloc(fsnotify_event_cachep, gfp); |
353 | if (!event) | 354 | if (!event) |
354 | return NULL; | 355 | return NULL; |
355 | 356 | ||
356 | initialize_event(event); | 357 | initialize_event(event); |
357 | 358 | ||
358 | if (name) { | 359 | if (name) { |
359 | event->file_name = kstrdup(name, GFP_KERNEL); | 360 | event->file_name = kstrdup(name, gfp); |
360 | if (!event->file_name) { | 361 | if (!event->file_name) { |
361 | kmem_cache_free(fsnotify_event_cachep, event); | 362 | kmem_cache_free(fsnotify_event_cachep, event); |
362 | return NULL; | 363 | return NULL; |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 6c3de999fb34..4d6f47b51189 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -352,7 +352,7 @@ extern void fsnotify_unmount_inodes(struct list_head *list); | |||
352 | /* put here because inotify does some weird stuff when destroying watches */ | 352 | /* put here because inotify does some weird stuff when destroying watches */ |
353 | extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | 353 | extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, |
354 | void *data, int data_is, const char *name, | 354 | void *data, int data_is, const char *name, |
355 | u32 cookie); | 355 | u32 cookie, gfp_t gfp); |
356 | 356 | ||
357 | #else | 357 | #else |
358 | 358 | ||