Lines Matching +full:event +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * the event happened. When inotify gets an event it will need to add that
10 * event to the group notify queue. Since a single event might need to be on
11 * multiple group's notification queues we can't add the event directly to each
13 * has a pointer back to the original event. Since the majority of events are
15 * event_holder into each event. This means we have a single allocation instead
41 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
51 struct fsnotify_event *event) in fsnotify_destroy_event() argument
53 /* Overflow events are per-group and we don't want to free them */ in fsnotify_destroy_event()
54 if (!event || event == group->overflow_event) in fsnotify_destroy_event()
57 * If the event is still queued, we have a problem... Do an unreliable in fsnotify_destroy_event()
60 * from the list by a different CPU than the one freeing the event. in fsnotify_destroy_event()
62 if (!list_empty(&event->list)) { in fsnotify_destroy_event()
63 spin_lock(&group->notification_lock); in fsnotify_destroy_event()
64 WARN_ON(!list_empty(&event->list)); in fsnotify_destroy_event()
65 spin_unlock(&group->notification_lock); in fsnotify_destroy_event()
67 group->ops->free_event(group, event); in fsnotify_destroy_event()
71 * Try to add an event to the notification queue.
72 * The group can later pull this event off the queue to deal with.
73 * The group can use the @merge hook to merge the event with a queued event.
74 * The group can use the @insert hook to insert the event into hash table.
76 * 0 if the event was added to a queue
77 * 1 if the event was merged with some other queued event
78 * 2 if the event was not queued - either the queue of events has overflown
82 struct fsnotify_event *event, in fsnotify_insert_event() argument
89 struct list_head *list = &group->notification_list; in fsnotify_insert_event()
91 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in fsnotify_insert_event()
93 spin_lock(&group->notification_lock); in fsnotify_insert_event()
95 if (group->shutdown) { in fsnotify_insert_event()
96 spin_unlock(&group->notification_lock); in fsnotify_insert_event()
100 if (event == group->overflow_event || in fsnotify_insert_event()
101 group->q_len >= group->max_events) { in fsnotify_insert_event()
103 /* Queue overflow event only if it isn't already queued */ in fsnotify_insert_event()
104 if (!list_empty(&group->overflow_event->list)) { in fsnotify_insert_event()
105 spin_unlock(&group->notification_lock); in fsnotify_insert_event()
108 event = group->overflow_event; in fsnotify_insert_event()
113 ret = merge(group, event); in fsnotify_insert_event()
115 spin_unlock(&group->notification_lock); in fsnotify_insert_event()
121 group->q_len++; in fsnotify_insert_event()
122 list_add_tail(&event->list, list); in fsnotify_insert_event()
124 insert(group, event); in fsnotify_insert_event()
125 spin_unlock(&group->notification_lock); in fsnotify_insert_event()
127 wake_up(&group->notification_waitq); in fsnotify_insert_event()
128 kill_fasync(&group->fsn_fa, SIGIO, POLL_IN); in fsnotify_insert_event()
133 struct fsnotify_event *event) in fsnotify_remove_queued_event() argument
135 assert_spin_locked(&group->notification_lock); in fsnotify_remove_queued_event()
137 * We need to init list head for the case of overflow event so that in fsnotify_remove_queued_event()
140 list_del_init(&event->list); in fsnotify_remove_queued_event()
141 group->q_len--; in fsnotify_remove_queued_event()
145 * Return the first event on the notification list without removing it.
150 assert_spin_locked(&group->notification_lock); in fsnotify_peek_first_event()
155 return list_first_entry(&group->notification_list, in fsnotify_peek_first_event()
160 * Remove and return the first event from the notification list. It is the
161 * responsibility of the caller to destroy the obtained event
165 struct fsnotify_event *event = fsnotify_peek_first_event(group); in fsnotify_remove_first_event() local
167 if (!event) in fsnotify_remove_first_event()
170 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in fsnotify_remove_first_event()
172 fsnotify_remove_queued_event(group, event); in fsnotify_remove_first_event()
174 return event; in fsnotify_remove_first_event()
179 * event notifications.
183 struct fsnotify_event *event; in fsnotify_flush_notify() local
185 spin_lock(&group->notification_lock); in fsnotify_flush_notify()
187 event = fsnotify_remove_first_event(group); in fsnotify_flush_notify()
188 spin_unlock(&group->notification_lock); in fsnotify_flush_notify()
189 fsnotify_destroy_event(group, event); in fsnotify_flush_notify()
190 spin_lock(&group->notification_lock); in fsnotify_flush_notify()
192 spin_unlock(&group->notification_lock); in fsnotify_flush_notify()