ARM64: dts: rk3368: add vop display node
[firefly-linux-kernel-4.4.55.git] / fs / notify / notification.c
index 1e58402171a56cd9d078ab62307951689a5630df..e455e83ceeebc9ea5cb0b3166e10bd505cec43f1 100644 (file)
@@ -73,7 +73,8 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
        /* Overflow events are per-group and we don't want to free them */
        if (!event || event->mask == FS_Q_OVERFLOW)
                return;
-
+       /* If the event is still queued, we have a problem... */
+       WARN_ON(!list_empty(&event->list));
        group->ops->free_event(event);
 }
 
@@ -81,12 +82,13 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
  * Add an event to the group notification queue.  The group can later pull this
  * event off the queue to deal with.  The function returns 0 if the event was
  * added to the queue, 1 if the event was merged with some other queued event,
- * 2 if the queue of events has overflown.
+ * 2 if the event was not queued - either the queue of events has overflown
+ * or the group is shutting down.
  */
-int fsnotify_add_notify_event(struct fsnotify_group *group,
-                             struct fsnotify_event *event,
-                             int (*merge)(struct list_head *,
-                                          struct fsnotify_event *))
+int fsnotify_add_event(struct fsnotify_group *group,
+                      struct fsnotify_event *event,
+                      int (*merge)(struct list_head *,
+                                   struct fsnotify_event *))
 {
        int ret = 0;
        struct list_head *list = &group->notification_list;
@@ -95,6 +97,11 @@ int fsnotify_add_notify_event(struct fsnotify_group *group,
 
        mutex_lock(&group->notification_mutex);
 
+       if (group->shutdown) {
+               mutex_unlock(&group->notification_mutex);
+               return 2;
+       }
+
        if (group->q_len >= group->max_events) {
                ret = 2;
                /* Queue overflow event only if it isn't already queued */
@@ -128,7 +135,7 @@ queue:
  * Remove and return the first event from the notification list.  It is the
  * responsibility of the caller to destroy the obtained event
  */
-struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group)
+struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group)
 {
        struct fsnotify_event *event;
 
@@ -140,7 +147,7 @@ struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group
                                 struct fsnotify_event, list);
        /*
         * We need to init list head for the case of overflow event so that
-        * check in fsnotify_add_notify_events() works
+        * check in fsnotify_add_event() works
         */
        list_del_init(&event->list);
        group->q_len--;
@@ -149,9 +156,10 @@ struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group
 }
 
 /*
- * This will not remove the event, that must be done with fsnotify_remove_notify_event()
+ * This will not remove the event, that must be done with
+ * fsnotify_remove_first_event()
  */
-struct fsnotify_event *fsnotify_peek_notify_event(struct fsnotify_group *group)
+struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group)
 {
        BUG_ON(!mutex_is_locked(&group->notification_mutex));
 
@@ -169,7 +177,7 @@ void fsnotify_flush_notify(struct fsnotify_group *group)
 
        mutex_lock(&group->notification_mutex);
        while (!fsnotify_notify_queue_is_empty(group)) {
-               event = fsnotify_remove_notify_event(group);
+               event = fsnotify_remove_first_event(group);
                fsnotify_destroy_event(group, event);
        }
        mutex_unlock(&group->notification_mutex);