hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/notify/notification.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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.
174 */
185
196 /*
....@@ -71,7 +58,7 @@
7158 struct fsnotify_event *event)
7259 {
7360 /* 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)
7562 return;
7663 /*
7764 * If the event is still queued, we have a problem... Do an unreliable
....@@ -141,6 +128,18 @@
141128 return ret;
142129 }
143130
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
+
144143 /*
145144 * Remove and return the first event from the notification list. It is the
146145 * responsibility of the caller to destroy the obtained event
....@@ -155,13 +154,7 @@
155154
156155 event = list_first_entry(&group->notification_list,
157156 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);
165158 return event;
166159 }
167160
....@@ -193,24 +186,4 @@
193186 spin_lock(&group->notification_lock);
194187 }
195188 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;
216189 }