aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorLino Sanfilippo <LinoSanfilippo@gmx.de>2011-06-14 11:29:45 -0400
committerEric Paris <eparis@redhat.com>2012-12-11 13:29:43 -0500
commitd8153d4d8b7b6141770e1416c4a338161205ed1b (patch)
treee353338c1b5be16c5b0d2bc4f1f698d982a00319 /fs/notify
parenta0d271cbfed1dd50278c6b06bead3d00ba0a88f9 (diff)
inotify, fanotify: replace fsnotify_put_group() with fsnotify_destroy_group()
Currently in fsnotify_put_group() the ref count of a group is decremented and if it becomes 0 fsnotify_destroy_group() is called. Since a groups ref count is only at group creation set to 1 and never increased after that a call to fsnotify_put_group() always results in a call to fsnotify_destroy_group(). With this patch fsnotify_destroy_group() is called directly. Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c14
-rw-r--r--fs/notify/group.c2
-rw-r--r--fs/notify/inotify/inotify_user.c8
3 files changed, 11 insertions, 13 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index d43803669739..82ae6d783c14 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -415,7 +415,7 @@ static int fanotify_release(struct inode *ignored, struct file *file)
415 wake_up(&group->fanotify_data.access_waitq); 415 wake_up(&group->fanotify_data.access_waitq);
416#endif 416#endif
417 /* matches the fanotify_init->fsnotify_alloc_group */ 417 /* matches the fanotify_init->fsnotify_alloc_group */
418 fsnotify_put_group(group); 418 fsnotify_destroy_group(group);
419 419
420 return 0; 420 return 0;
421} 421}
@@ -728,13 +728,13 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
728 break; 728 break;
729 default: 729 default:
730 fd = -EINVAL; 730 fd = -EINVAL;
731 goto out_put_group; 731 goto out_destroy_group;
732 } 732 }
733 733
734 if (flags & FAN_UNLIMITED_QUEUE) { 734 if (flags & FAN_UNLIMITED_QUEUE) {
735 fd = -EPERM; 735 fd = -EPERM;
736 if (!capable(CAP_SYS_ADMIN)) 736 if (!capable(CAP_SYS_ADMIN))
737 goto out_put_group; 737 goto out_destroy_group;
738 group->max_events = UINT_MAX; 738 group->max_events = UINT_MAX;
739 } else { 739 } else {
740 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; 740 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
@@ -743,7 +743,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
743 if (flags & FAN_UNLIMITED_MARKS) { 743 if (flags & FAN_UNLIMITED_MARKS) {
744 fd = -EPERM; 744 fd = -EPERM;
745 if (!capable(CAP_SYS_ADMIN)) 745 if (!capable(CAP_SYS_ADMIN))
746 goto out_put_group; 746 goto out_destroy_group;
747 group->fanotify_data.max_marks = UINT_MAX; 747 group->fanotify_data.max_marks = UINT_MAX;
748 } else { 748 } else {
749 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS; 749 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS;
@@ -751,12 +751,12 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
751 751
752 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); 752 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
753 if (fd < 0) 753 if (fd < 0)
754 goto out_put_group; 754 goto out_destroy_group;
755 755
756 return fd; 756 return fd;
757 757
758out_put_group: 758out_destroy_group:
759 fsnotify_put_group(group); 759 fsnotify_destroy_group(group);
760 return fd; 760 return fd;
761} 761}
762 762
diff --git a/fs/notify/group.c b/fs/notify/group.c
index 63fc294a4692..cfda328c3d11 100644
--- a/fs/notify/group.c
+++ b/fs/notify/group.c
@@ -50,7 +50,7 @@ void fsnotify_final_destroy_group(struct fsnotify_group *group)
50 * situtation, the fsnotify_final_destroy_group will get called when that final 50 * situtation, the fsnotify_final_destroy_group will get called when that final
51 * mark is freed. 51 * mark is freed.
52 */ 52 */
53static void fsnotify_destroy_group(struct fsnotify_group *group) 53void fsnotify_destroy_group(struct fsnotify_group *group)
54{ 54{
55 /* clear all inode marks for this group */ 55 /* clear all inode marks for this group */
56 fsnotify_clear_marks_by_group(group); 56 fsnotify_clear_marks_by_group(group);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 8445fbc8985c..dbafbfc8ceca 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -293,10 +293,8 @@ static int inotify_release(struct inode *ignored, struct file *file)
293 293
294 pr_debug("%s: group=%p\n", __func__, group); 294 pr_debug("%s: group=%p\n", __func__, group);
295 295
296 fsnotify_clear_marks_by_group(group);
297
298 /* free this group, matching get was inotify_init->fsnotify_obtain_group */ 296 /* free this group, matching get was inotify_init->fsnotify_obtain_group */
299 fsnotify_put_group(group); 297 fsnotify_destroy_group(group);
300 298
301 return 0; 299 return 0;
302} 300}
@@ -712,7 +710,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
712 710
713 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > 711 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) >
714 inotify_max_user_instances) { 712 inotify_max_user_instances) {
715 fsnotify_put_group(group); 713 fsnotify_destroy_group(group);
716 return ERR_PTR(-EMFILE); 714 return ERR_PTR(-EMFILE);
717 } 715 }
718 716
@@ -741,7 +739,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
741 ret = anon_inode_getfd("inotify", &inotify_fops, group, 739 ret = anon_inode_getfd("inotify", &inotify_fops, group,
742 O_RDONLY | flags); 740 O_RDONLY | flags);
743 if (ret < 0) 741 if (ret < 0)
744 fsnotify_put_group(group); 742 fsnotify_destroy_group(group);
745 743
746 return ret; 744 return ret;
747} 745}