fsnotify: cleanup should_send_event
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 <eparis@redhat.com>
This commit is contained in:
parent
0215054f37
commit
2612abb51b
|
@ -129,20 +129,11 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
|
||||||
struct fsnotify_mark *mark, __u32 mask,
|
struct fsnotify_mark *mark, __u32 mask,
|
||||||
void *data, int data_type)
|
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 */
|
/* not a dir, dnotify doesn't care */
|
||||||
if (!S_ISDIR(inode->i_mode))
|
if (!S_ISDIR(inode->i_mode))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mask = (mask & ~FS_EVENT_ON_CHILD);
|
return true;
|
||||||
send = (mask & mark->mask);
|
|
||||||
|
|
||||||
return send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
|
static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
|
||||||
|
|
|
@ -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",
|
pr_debug("%s: group=%p inode=%p mark=%p mask=%x\n",
|
||||||
__func__, group, inode, mark, mask);
|
__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 ((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
|
* if the event is for a child and this inode doesn't care about
|
||||||
* type of event?
|
* events on the child, don't send it!
|
||||||
*/
|
*/
|
||||||
mask &= ~FS_EVENT_ON_CHILD;
|
if ((mask & FS_EVENT_ON_CHILD) &&
|
||||||
mask &= mark->mask;
|
!(mark->mask & FS_EVENT_ON_CHILD))
|
||||||
mask &= ~mark->ignored_mask;
|
return false;
|
||||||
}
|
else
|
||||||
|
return true;
|
||||||
return mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
|
static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
|
||||||
|
|
|
@ -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,
|
" data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
|
||||||
mnt, mark, mask, data, data_is, cookie, *event);
|
mnt, mark, mask, data, data_is, cookie, *event);
|
||||||
|
|
||||||
if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
|
if (group->ops->should_send_event(group, to_tell, mnt, mark, mask,
|
||||||
data, data_is))
|
data, data_is) == false)
|
||||||
return 0;
|
return 0;
|
||||||
if (!*event) {
|
if (!*event) {
|
||||||
*event = fsnotify_create_event(to_tell, mask, data,
|
*event = fsnotify_create_event(to_tell, mask, data,
|
||||||
|
|
|
@ -142,23 +142,15 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
|
||||||
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
||||||
__u32 mask, void *data, int data_type)
|
__u32 mask, void *data, int data_type)
|
||||||
{
|
{
|
||||||
bool send;
|
if ((mark->mask & FS_EXCL_UNLINK) &&
|
||||||
|
|
||||||
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) &&
|
|
||||||
(data_type == FSNOTIFY_EVENT_FILE)) {
|
(data_type == FSNOTIFY_EVENT_FILE)) {
|
||||||
struct file *file = data;
|
struct file *file = data;
|
||||||
|
|
||||||
if (d_unlinked(file->f_path.dentry))
|
if (d_unlinked(file->f_path.dentry))
|
||||||
send = false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return send;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -923,7 +923,7 @@ static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *in
|
||||||
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
||||||
__u32 mask, void *data, int data_type)
|
__u32 mask, void *data, int data_type)
|
||||||
{
|
{
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct fsnotify_ops audit_tree_ops = {
|
static const struct fsnotify_ops audit_tree_ops = {
|
||||||
|
|
|
@ -514,12 +514,7 @@ static bool audit_watch_should_send_event(struct fsnotify_group *group, struct i
|
||||||
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
struct vfsmount *mnt, struct fsnotify_mark *mark,
|
||||||
__u32 mask, void *data, int data_type)
|
__u32 mask, void *data, int data_type)
|
||||||
{
|
{
|
||||||
bool send;
|
return true;
|
||||||
|
|
||||||
mask = (mask & ~FS_EVENT_ON_CHILD);
|
|
||||||
send = (mark->mask & mask);
|
|
||||||
|
|
||||||
return send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update watch data in audit rules based on fsnotify events. */
|
/* Update watch data in audit rules based on fsnotify events. */
|
||||||
|
|
Loading…
Reference in New Issue