aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-12-17 21:24:28 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:58 -0400
commit088b09b0ac7a866a35962eeaea5d5607bd1840b7 (patch)
tree9028cacd5ef98f34abeaa8fb68289745e0aaba20 /fs
parentc6223f464927cab9f4b10169b78c51d84228faf8 (diff)
fanotify: do not call fanotify_update_object_mask in fanotify_remove_mark
Recalculate masks in fanotify_remove_mark, don't use fanotify_update_object_mask. This gets us one step closers to readable code. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/notify/fanotify/fanotify_user.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 0f25fc20a6a7..96d4ffd72519 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -353,10 +353,26 @@ static void fanotify_update_object_mask(struct fsnotify_group *group,
353 } 353 }
354} 354}
355 355
356static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark, __u32 mask)
357{
358 __u32 oldmask;
359
360 spin_lock(&fsn_mark->lock);
361 oldmask = fsn_mark->mask;
362 fsn_mark->mask = oldmask & ~mask;
363 spin_unlock(&fsn_mark->lock);
364
365 if (!(oldmask & ~mask))
366 fsnotify_destroy_mark(fsn_mark);
367
368 return mask & oldmask;
369}
370
356static int fanotify_remove_mark(struct fsnotify_group *group, struct inode *inode, 371static int fanotify_remove_mark(struct fsnotify_group *group, struct inode *inode,
357 struct vfsmount *mnt, unsigned int flags, __u32 mask) 372 struct vfsmount *mnt, __u32 mask)
358{ 373{
359 struct fsnotify_mark *fsn_mark = NULL; 374 struct fsnotify_mark *fsn_mark = NULL;
375 __u32 removed;
360 376
361 BUG_ON(inode && mnt); 377 BUG_ON(inode && mnt);
362 BUG_ON(!inode && !mnt); 378 BUG_ON(!inode && !mnt);
@@ -371,11 +387,20 @@ static int fanotify_remove_mark(struct fsnotify_group *group, struct inode *inod
371 if (!fsn_mark) 387 if (!fsn_mark)
372 return -ENOENT; 388 return -ENOENT;
373 389
374 fanotify_update_object_mask(group, inode, mnt, fsn_mark, flags, mask); 390 removed = fanotify_mark_remove_from_mask(fsn_mark, mask);
375
376 /* matches the fsnotify_find_inode_mark() */ 391 /* matches the fsnotify_find_inode_mark() */
377 fsnotify_put_mark(fsn_mark); 392 fsnotify_put_mark(fsn_mark);
378 393
394 if (removed & group->mask)
395 fsnotify_recalc_group_mask(group);
396 if (inode) {
397 if (removed & inode->i_fsnotify_mask)
398 fsnotify_recalc_inode_mask(inode);
399 } else if (mnt) {
400 if (removed & mnt->mnt_fsnotify_mask)
401 fsnotify_recalc_vfsmount_mask(mnt);
402 }
403
379 return 0; 404 return 0;
380} 405}
381 406
@@ -568,7 +593,7 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
568 ret = fanotify_add_mark(group, inode, NULL, flags, mask); 593 ret = fanotify_add_mark(group, inode, NULL, flags, mask);
569 break; 594 break;
570 case FAN_MARK_REMOVE: 595 case FAN_MARK_REMOVE:
571 ret = fanotify_remove_mark(group, inode, NULL, flags, mask); 596 ret = fanotify_remove_mark(group, inode, NULL, mask);
572 break; 597 break;
573 default: 598 default:
574 ret = -EINVAL; 599 ret = -EINVAL;