.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2008 Red Hat, Inc., Eric Paris <eparis@redhat.com> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; either version 2, or (at your option) |
---|
7 | | - * any later version. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope that it will be useful, |
---|
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | | - * GNU General Public License for more details. |
---|
13 | | - * |
---|
14 | | - * You should have received a copy of the GNU General Public License |
---|
15 | | - * along with this program; see the file COPYING. If not, write to |
---|
16 | | - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
17 | 4 | */ |
---|
18 | 5 | |
---|
19 | 6 | /* |
---|
.. | .. |
---|
71 | 58 | struct fsnotify_event *event) |
---|
72 | 59 | { |
---|
73 | 60 | /* Overflow events are per-group and we don't want to free them */ |
---|
74 | | - if (!event || event->mask == FS_Q_OVERFLOW) |
---|
| 61 | + if (!event || event == group->overflow_event) |
---|
75 | 62 | return; |
---|
76 | 63 | /* |
---|
77 | 64 | * If the event is still queued, we have a problem... Do an unreliable |
---|
.. | .. |
---|
141 | 128 | return ret; |
---|
142 | 129 | } |
---|
143 | 130 | |
---|
| 131 | +void fsnotify_remove_queued_event(struct fsnotify_group *group, |
---|
| 132 | + struct fsnotify_event *event) |
---|
| 133 | +{ |
---|
| 134 | + assert_spin_locked(&group->notification_lock); |
---|
| 135 | + /* |
---|
| 136 | + * We need to init list head for the case of overflow event so that |
---|
| 137 | + * check in fsnotify_add_event() works |
---|
| 138 | + */ |
---|
| 139 | + list_del_init(&event->list); |
---|
| 140 | + group->q_len--; |
---|
| 141 | +} |
---|
| 142 | + |
---|
144 | 143 | /* |
---|
145 | 144 | * Remove and return the first event from the notification list. It is the |
---|
146 | 145 | * responsibility of the caller to destroy the obtained event |
---|
.. | .. |
---|
155 | 154 | |
---|
156 | 155 | event = list_first_entry(&group->notification_list, |
---|
157 | 156 | struct fsnotify_event, list); |
---|
158 | | - /* |
---|
159 | | - * We need to init list head for the case of overflow event so that |
---|
160 | | - * check in fsnotify_add_event() works |
---|
161 | | - */ |
---|
162 | | - list_del_init(&event->list); |
---|
163 | | - group->q_len--; |
---|
164 | | - |
---|
| 157 | + fsnotify_remove_queued_event(group, event); |
---|
165 | 158 | return event; |
---|
166 | 159 | } |
---|
167 | 160 | |
---|
.. | .. |
---|
193 | 186 | spin_lock(&group->notification_lock); |
---|
194 | 187 | } |
---|
195 | 188 | spin_unlock(&group->notification_lock); |
---|
196 | | -} |
---|
197 | | - |
---|
198 | | -/* |
---|
199 | | - * fsnotify_create_event - Allocate a new event which will be sent to each |
---|
200 | | - * group's handle_event function if the group was interested in this |
---|
201 | | - * particular event. |
---|
202 | | - * |
---|
203 | | - * @inode the inode which is supposed to receive the event (sometimes a |
---|
204 | | - * parent of the inode to which the event happened. |
---|
205 | | - * @mask what actually happened. |
---|
206 | | - * @data pointer to the object which was actually affected |
---|
207 | | - * @data_type flag indication if the data is a file, path, inode, nothing... |
---|
208 | | - * @name the filename, if available |
---|
209 | | - */ |
---|
210 | | -void fsnotify_init_event(struct fsnotify_event *event, struct inode *inode, |
---|
211 | | - u32 mask) |
---|
212 | | -{ |
---|
213 | | - INIT_LIST_HEAD(&event->list); |
---|
214 | | - event->inode = inode; |
---|
215 | | - event->mask = mask; |
---|
216 | 189 | } |
---|