aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-04-03 17:46:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:20:51 -0400
commitd8aaab4f619acfbfafc91d94b15c2932457c65fa (patch)
treed73ebf86269bf349e2949dfe14dbb2f36f179a59 /fs/notify
parent9573f79355ff3711c98227d14a9b7f4cb3222b97 (diff)
fanotify: reorganize loop in fanotify_read()
Swap the error / "read ok" branches in the main loop of fanotify_read(). We will grow the "read ok" part in the next patch and this makes the indentation easier. Also it is more common to have error conditions inside an 'if' instead of the fast path. Signed-off-by: Jan Kara <jack@suse.cz> Cc: Eric Paris <eparis@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 2a57278afb80..f1097f56137e 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -275,35 +275,37 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
275 kevent = get_one_event(group, count); 275 kevent = get_one_event(group, count);
276 mutex_unlock(&group->notification_mutex); 276 mutex_unlock(&group->notification_mutex);
277 277
278 if (kevent) { 278 if (IS_ERR(kevent)) {
279 ret = PTR_ERR(kevent); 279 ret = PTR_ERR(kevent);
280 if (IS_ERR(kevent)) 280 break;
281 }
282
283 if (!kevent) {
284 ret = -EAGAIN;
285 if (file->f_flags & O_NONBLOCK)
281 break; 286 break;
282 ret = copy_event_to_user(group, kevent, buf); 287
283 /* 288 ret = -ERESTARTSYS;
284 * Permission events get queued to wait for response. 289 if (signal_pending(current))
285 * Other events can be destroyed now. 290 break;
286 */ 291
287 if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) 292 if (start != buf)
288 fsnotify_destroy_event(group, kevent);
289 if (ret < 0)
290 break; 293 break;
291 buf += ret; 294 schedule();
292 count -= ret;
293 continue; 295 continue;
294 } 296 }
295 297
296 ret = -EAGAIN; 298 ret = copy_event_to_user(group, kevent, buf);
297 if (file->f_flags & O_NONBLOCK) 299 /*
298 break; 300 * Permission events get queued to wait for response. Other
299 ret = -ERESTARTSYS; 301 * events can be destroyed now.
300 if (signal_pending(current)) 302 */
301 break; 303 if (!(kevent->mask & FAN_ALL_PERM_EVENTS))
302 304 fsnotify_destroy_event(group, kevent);
303 if (start != buf) 305 if (ret < 0)
304 break; 306 break;
305 307 buf += ret;
306 schedule(); 308 count -= ret;
307 } 309 }
308 310
309 finish_wait(&group->notification_waitq, &wait); 311 finish_wait(&group->notification_waitq, &wait);