aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/notification.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2010-07-28 10:18:37 -0400
committerEric Paris <eparis@redhat.com>2010-07-28 10:18:50 -0400
commitf70ab54cc6c3907b0727ba332b3976f80f3846d0 (patch)
tree2a22097325a668a0d08d4ea3354d0e6c95fddd86 /fs/notify/notification.c
parent5ba08e2eeb06355f66ed62ae97bb87d145973a9a (diff)
fsnotify: fsnotify_add_notify_event should return an event
Rather than the horrific void ** argument and such just to pass the fanotify_merge event back to the caller of fsnotify_add_notify_event() have those things return an event if it was different than the event suggusted to be added. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/notification.c')
-rw-r--r--fs/notify/notification.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index e6dde25fb99b..f39260f8f865 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -137,16 +137,14 @@ struct fsnotify_event_private_data *fsnotify_remove_priv_from_event(struct fsnot
137 * event off the queue to deal with. If the event is successfully added to the 137 * event off the queue to deal with. If the event is successfully added to the
138 * group's notification queue, a reference is taken on event. 138 * group's notification queue, a reference is taken on event.
139 */ 139 */
140int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_event *event, 140struct fsnotify_event *fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_event *event,
141 struct fsnotify_event_private_data *priv, 141 struct fsnotify_event_private_data *priv,
142 int (*merge)(struct list_head *, 142 struct fsnotify_event *(*merge)(struct list_head *,
143 struct fsnotify_event *, 143 struct fsnotify_event *))
144 void **arg),
145 void **arg)
146{ 144{
145 struct fsnotify_event *return_event = NULL;
147 struct fsnotify_event_holder *holder = NULL; 146 struct fsnotify_event_holder *holder = NULL;
148 struct list_head *list = &group->notification_list; 147 struct list_head *list = &group->notification_list;
149 int rc = 0;
150 148
151 pr_debug("%s: group=%p event=%p priv=%p\n", __func__, group, event, priv); 149 pr_debug("%s: group=%p event=%p priv=%p\n", __func__, group, event, priv);
152 150
@@ -162,27 +160,37 @@ int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_even
162alloc_holder: 160alloc_holder:
163 holder = fsnotify_alloc_event_holder(); 161 holder = fsnotify_alloc_event_holder();
164 if (!holder) 162 if (!holder)
165 return -ENOMEM; 163 return ERR_PTR(-ENOMEM);
166 } 164 }
167 165
168 mutex_lock(&group->notification_mutex); 166 mutex_lock(&group->notification_mutex);
169 167
170 if (group->q_len >= group->max_events) { 168 if (group->q_len >= group->max_events) {
171 event = q_overflow_event; 169 event = q_overflow_event;
172 rc = -EOVERFLOW; 170
171 /*
172 * we need to return the overflow event
173 * which means we need a ref
174 */
175 fsnotify_get_event(event);
176 return_event = event;
177
173 /* sorry, no private data on the overflow event */ 178 /* sorry, no private data on the overflow event */
174 priv = NULL; 179 priv = NULL;
175 } 180 }
176 181
177 if (!list_empty(list) && merge) { 182 if (!list_empty(list) && merge) {
178 int ret; 183 struct fsnotify_event *tmp;
179 184
180 ret = merge(list, event, arg); 185 tmp = merge(list, event);
181 if (ret) { 186 if (tmp) {
182 mutex_unlock(&group->notification_mutex); 187 mutex_unlock(&group->notification_mutex);
188
189 if (return_event)
190 fsnotify_put_event(return_event);
183 if (holder != &event->holder) 191 if (holder != &event->holder)
184 fsnotify_destroy_event_holder(holder); 192 fsnotify_destroy_event_holder(holder);
185 return ret; 193 return tmp;
186 } 194 }
187 } 195 }
188 196
@@ -197,6 +205,12 @@ alloc_holder:
197 * event holder was used, go back and get a new one */ 205 * event holder was used, go back and get a new one */
198 spin_unlock(&event->lock); 206 spin_unlock(&event->lock);
199 mutex_unlock(&group->notification_mutex); 207 mutex_unlock(&group->notification_mutex);
208
209 if (return_event) {
210 fsnotify_put_event(return_event);
211 return_event = NULL;
212 }
213
200 goto alloc_holder; 214 goto alloc_holder;
201 } 215 }
202 216
@@ -211,7 +225,7 @@ alloc_holder:
211 mutex_unlock(&group->notification_mutex); 225 mutex_unlock(&group->notification_mutex);
212 226
213 wake_up(&group->notification_waitq); 227 wake_up(&group->notification_waitq);
214 return rc; 228 return return_event;
215} 229}
216 230
217/* 231/*