diff options
-rw-r--r-- | fs/notify/fanotify/fanotify.c | 6 | ||||
-rw-r--r-- | fs/notify/notification.c | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 205dc2163822..dc638f786d5c 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c | |||
@@ -192,10 +192,12 @@ static int fanotify_handle_event(struct fsnotify_group *group, | |||
192 | 192 | ||
193 | ret = fsnotify_add_notify_event(group, fsn_event, fanotify_merge); | 193 | ret = fsnotify_add_notify_event(group, fsn_event, fanotify_merge); |
194 | if (ret) { | 194 | if (ret) { |
195 | BUG_ON(mask & FAN_ALL_PERM_EVENTS); | 195 | /* Permission events shouldn't be merged */ |
196 | BUG_ON(ret == 1 && mask & FAN_ALL_PERM_EVENTS); | ||
196 | /* Our event wasn't used in the end. Free it. */ | 197 | /* Our event wasn't used in the end. Free it. */ |
197 | fsnotify_destroy_event(group, fsn_event); | 198 | fsnotify_destroy_event(group, fsn_event); |
198 | ret = 0; | 199 | |
200 | return 0; | ||
199 | } | 201 | } |
200 | 202 | ||
201 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 203 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 6bec2f4918f9..6a4ba17c0395 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c | |||
@@ -80,7 +80,8 @@ void fsnotify_destroy_event(struct fsnotify_group *group, | |||
80 | /* | 80 | /* |
81 | * Add an event to the group notification queue. The group can later pull this | 81 | * Add an event to the group notification queue. The group can later pull this |
82 | * event off the queue to deal with. The function returns 0 if the event was | 82 | * event off the queue to deal with. The function returns 0 if the event was |
83 | * added to the queue, 1 if the event was merged with some other queued event. | 83 | * added to the queue, 1 if the event was merged with some other queued event, |
84 | * 2 if the queue of events has overflown. | ||
84 | */ | 85 | */ |
85 | int fsnotify_add_notify_event(struct fsnotify_group *group, | 86 | int fsnotify_add_notify_event(struct fsnotify_group *group, |
86 | struct fsnotify_event *event, | 87 | struct fsnotify_event *event, |
@@ -95,10 +96,14 @@ int fsnotify_add_notify_event(struct fsnotify_group *group, | |||
95 | mutex_lock(&group->notification_mutex); | 96 | mutex_lock(&group->notification_mutex); |
96 | 97 | ||
97 | if (group->q_len >= group->max_events) { | 98 | if (group->q_len >= group->max_events) { |
99 | ret = 2; | ||
98 | /* Queue overflow event only if it isn't already queued */ | 100 | /* Queue overflow event only if it isn't already queued */ |
99 | if (list_empty(&group->overflow_event.list)) | 101 | if (!list_empty(&group->overflow_event.list)) { |
100 | event = &group->overflow_event; | 102 | mutex_unlock(&group->notification_mutex); |
101 | ret = 1; | 103 | return ret; |
104 | } | ||
105 | event = &group->overflow_event; | ||
106 | goto queue; | ||
102 | } | 107 | } |
103 | 108 | ||
104 | if (!list_empty(list) && merge) { | 109 | if (!list_empty(list) && merge) { |
@@ -109,6 +114,7 @@ int fsnotify_add_notify_event(struct fsnotify_group *group, | |||
109 | } | 114 | } |
110 | } | 115 | } |
111 | 116 | ||
117 | queue: | ||
112 | group->q_len++; | 118 | group->q_len++; |
113 | list_add_tail(&event->list, list); | 119 | list_add_tail(&event->list, list); |
114 | mutex_unlock(&group->notification_mutex); | 120 | mutex_unlock(&group->notification_mutex); |