Skip to content

Commit

Permalink
fsnotify: cleanup should_send_event
Browse files Browse the repository at this point in the history
The change to use srcu and walk the object list rather than the global
fsnotify_group list means that should_send_event is no longer needed for a
number of groups and can be simplified for others.  Do that.

Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
eparis committed Jul 28, 2010
1 parent 0215054 commit 2612abb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 45 deletions.
11 changes: 1 addition & 10 deletions fs/notify/dnotify/dnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,11 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
struct fsnotify_mark *mark, __u32 mask,
void *data, int data_type)
{
bool send;

/* !dir_notify_enable should never get here, don't waste time checking
if (!dir_notify_enable)
return 0; */

/* not a dir, dnotify doesn't care */
if (!S_ISDIR(inode->i_mode))
return false;

mask = (mask & ~FS_EVENT_ON_CHILD);
send = (mask & mark->mask);

return send;
return true;
}

static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
Expand Down
23 changes: 8 additions & 15 deletions fs/notify/fanotify/fanotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,15 @@ static bool should_send_inode_event(struct fsnotify_group *group,
pr_debug("%s: group=%p inode=%p mark=%p mask=%x\n",
__func__, group, inode, mark, mask);

/* if the event is for a child and this inode doesn't care about
* events on the child, don't send it! */
/*
* if the event is for a child and this inode doesn't care about
* events on the child, don't send it!
*/
if ((mask & FS_EVENT_ON_CHILD) &&
!(mark->mask & FS_EVENT_ON_CHILD)) {
mask = 0;
} else {
/*
* We care about children, but do we care about this particular
* type of event?
*/
mask &= ~FS_EVENT_ON_CHILD;
mask &= mark->mask;
mask &= ~mark->ignored_mask;
}

return mask;
!(mark->mask & FS_EVENT_ON_CHILD))
return false;
else
return true;
}

static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
Expand Down
4 changes: 2 additions & 2 deletions fs/notify/fsnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
" data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
mnt, mark, mask, data, data_is, cookie, *event);

if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
data, data_is))
if (group->ops->should_send_event(group, to_tell, mnt, mark, mask,
data, data_is) == false)
return 0;
if (!*event) {
*event = fsnotify_create_event(to_tell, mask, data,
Expand Down
14 changes: 3 additions & 11 deletions fs/notify/inotify/inotify_fsnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,15 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
struct vfsmount *mnt, struct fsnotify_mark *mark,
__u32 mask, void *data, int data_type)
{
bool send;

pr_debug("%s: group=%p inode=%p mask=%x data=%p data_type=%d\n",
__func__, group, inode, mask, data, data_type);

mask = (mask & ~FS_EVENT_ON_CHILD);
send = (mark->mask & mask);

if (send && (mark->mask & FS_EXCL_UNLINK) &&
if ((mark->mask & FS_EXCL_UNLINK) &&
(data_type == FSNOTIFY_EVENT_FILE)) {
struct file *file = data;

if (d_unlinked(file->f_path.dentry))
send = false;
return false;
}

return send;
return true;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion kernel/audit_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *in
struct vfsmount *mnt, struct fsnotify_mark *mark,
__u32 mask, void *data, int data_type)
{
return 0;
return false;
}

static const struct fsnotify_ops audit_tree_ops = {
Expand Down
7 changes: 1 addition & 6 deletions kernel/audit_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,7 @@ static bool audit_watch_should_send_event(struct fsnotify_group *group, struct i
struct vfsmount *mnt, struct fsnotify_mark *mark,
__u32 mask, void *data, int data_type)
{
bool send;

mask = (mask & ~FS_EVENT_ON_CHILD);
send = (mark->mask & mask);

return send;
return true;
}

/* Update watch data in audit rules based on fsnotify events. */
Expand Down

0 comments on commit 2612abb

Please sign in to comment.