Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207689
b: refs/heads/master
c: cb2d429
h: refs/heads/master
i:
  207687: bf927a5
v: v3
  • Loading branch information
Eric Paris committed Jul 28, 2010
1 parent aeaecc2 commit 8e73dcb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4d92604cc90aa18bbbe0f6e23b7a9fdb612836d3
refs/heads/master: cb2d429faf2cae62d3c51e28099a181d5fe8c244
4 changes: 2 additions & 2 deletions trunk/fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags,

if (event_f_flags)
return -EINVAL;
if (priority)
return -EINVAL;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;
Expand All @@ -483,6 +481,8 @@ SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags,
if (IS_ERR(group))
return PTR_ERR(group);

group->priority = priority;

fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
if (fd < 0)
goto out_put_group;
Expand Down
40 changes: 38 additions & 2 deletions trunk/fs/notify/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,55 @@ void fsnotify_recalc_group_mask(struct fsnotify_group *group)

void fsnotify_add_vfsmount_group(struct fsnotify_group *group)
{
struct fsnotify_group *group_iter;
unsigned int priority = group->priority;

mutex_lock(&fsnotify_grp_mutex);

if (!group->on_vfsmount_group_list)
if (!group->on_vfsmount_group_list) {
list_for_each_entry(group_iter, &fsnotify_vfsmount_groups,
vfsmount_group_list) {
/* insert in front of this one? */
if (priority < group_iter->priority) {
/* list_add_tail() insert in front of group_iter */
list_add_tail_rcu(&group->inode_group_list,
&group_iter->inode_group_list);
goto out;
}
}

/* apparently we need to be the last entry */
list_add_tail_rcu(&group->vfsmount_group_list, &fsnotify_vfsmount_groups);
}
out:
group->on_vfsmount_group_list = 1;

mutex_unlock(&fsnotify_grp_mutex);
}

void fsnotify_add_inode_group(struct fsnotify_group *group)
{
struct fsnotify_group *group_iter;
unsigned int priority = group->priority;

mutex_lock(&fsnotify_grp_mutex);

if (!group->on_inode_group_list)
/* add to global group list, priority 0 first, UINT_MAX last */
if (!group->on_inode_group_list) {
list_for_each_entry(group_iter, &fsnotify_inode_groups,
inode_group_list) {
if (priority < group_iter->priority) {
/* list_add_tail() insert in front of group_iter */
list_add_tail_rcu(&group->inode_group_list,
&group_iter->inode_group_list);
goto out;
}
}

/* apparently we need to be the last entry */
list_add_tail_rcu(&group->inode_group_list, &fsnotify_inode_groups);
}
out:
group->on_inode_group_list = 1;

mutex_unlock(&fsnotify_grp_mutex);
Expand Down Expand Up @@ -226,6 +260,8 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
spin_lock_init(&group->mark_lock);
INIT_LIST_HEAD(&group->marks_list);

group->priority = UINT_MAX;

group->ops = ops;

return group;
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct fsnotify_group {
* a group */
struct list_head marks_list; /* all inode marks for this group */

unsigned int priority; /* order of this group compared to others */
/* prevents double list_del of group_list. protected by global fsnotify_grp_mutex */
bool on_inode_group_list;
bool on_vfsmount_group_list;
Expand Down

0 comments on commit 8e73dcb

Please sign in to comment.