summaryrefslogtreecommitdiff
path: root/fs/notify/inotify/inotify_fsnotify.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-02-21 15:07:52 +0100
committerJan Kara <jack@suse.cz>2018-02-27 10:25:33 +0100
commit7b1f641776e0c8b824fb10135168e4b683a9e2ba (patch)
tree80f394d89521008b6bcbc980e202d25d7f35973f /fs/notify/inotify/inotify_fsnotify.c
parent1f5eaa90010ed7cf0ae90a526c48657d02c6086f (diff)
fsnotify: Let userspace know about lost events due to ENOMEM
Currently if notification event is lost due to event allocation failing we ENOMEM, we just silently continue (except for fanotify permission events where we deny the access). This is undesirable as userspace has no way of knowing whether the notifications it got are complete or not. Treat lost events due to ENOMEM the same way as lost events due to queue overflow so that userspace knows something bad happened and it likely needs to rescan the filesystem. Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify/inotify/inotify_fsnotify.c')
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index 8b73332735ba..40dedb37a1f3 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -99,8 +99,14 @@ int inotify_handle_event(struct fsnotify_group *group,
fsn_mark);
event = kmalloc(alloc_len, GFP_KERNEL);
- if (unlikely(!event))
+ if (unlikely(!event)) {
+ /*
+ * Treat lost event due to ENOMEM the same way as queue
+ * overflow to let userspace know event was lost.
+ */
+ fsnotify_queue_overflow(group);
return -ENOMEM;
+ }
fsn_event = &event->fse;
fsnotify_init_event(fsn_event, inode, mask);