summaryrefslogtreecommitdiffstats
path: root/fs/notify/fsnotify.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-12-17 21:24:23 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:52 -0400
commit3a9fb89f4cd04c23e16397befba92efb5d989b74 (patch)
treef60b48c8cf488ad8952601ccbc6192b5f86ec900 /fs/notify/fsnotify.c
parent7131485a93679ff9a543b74df280cfd119eb03ca (diff)
fsnotify: include vfsmount in should_send_event when appropriate
To ensure that a group will not duplicate events when it receives it based on the vfsmount and the inode should_send_event test we should distinguish those two cases. We pass a vfsmount to this function so groups can make their own determinations. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/fsnotify.c')
-rw-r--r--fs/notify/fsnotify.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index a61aaa71082..78c440c343a 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -135,13 +135,12 @@ void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
}
EXPORT_SYMBOL_GPL(__fsnotify_parent);
-static void send_to_group(__u32 mask,
- struct fsnotify_group *group,
- void *data, int data_is, const char *file_name,
- u32 cookie, struct fsnotify_event **event,
- struct inode *to_tell)
+static void send_to_group(struct fsnotify_group *group, struct inode *to_tell,
+ struct vfsmount *mnt, __u32 mask, void *data,
+ int data_is, u32 cookie, const char *file_name,
+ struct fsnotify_event **event)
{
- if (!group->ops->should_send_event(group, to_tell, mask,
+ if (!group->ops->should_send_event(group, to_tell, mnt, mask,
data, data_is))
return;
if (!*event) {
@@ -159,15 +158,9 @@ static void send_to_group(__u32 mask,
group->ops->handle_event(group, *event);
}
-static bool needed_by_vfsmount(__u32 test_mask, void *data, int data_is)
+static bool needed_by_vfsmount(__u32 test_mask, struct vfsmount *mnt)
{
- struct path *path;
-
- if (data_is == FSNOTIFY_EVENT_PATH)
- path = (struct path *)data;
- else if (data_is == FSNOTIFY_EVENT_FILE)
- path = &((struct file *)data)->f_path;
- else
+ if (!mnt)
return false;
/* hook in this when mnt->mnt_fsnotify_mask is defined */
@@ -184,6 +177,7 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
{
struct fsnotify_group *group;
struct fsnotify_event *event = NULL;
+ struct vfsmount *mnt = NULL;
int idx;
/* global tests shouldn't care about events on child only the specific event */
__u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
@@ -198,10 +192,15 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
!(test_mask & fsnotify_vfsmount_mask))
return;
+ if (data_is == FSNOTIFY_EVENT_PATH)
+ mnt = ((struct path *)data)->mnt;
+ else if (data_is == FSNOTIFY_EVENT_FILE)
+ mnt = ((struct file *)data)->f_path.mnt;
+
/* if this inode's directed listeners don't care and nothing on the vfsmount
* listeners list cares, nothing to do */
if (!(test_mask & to_tell->i_fsnotify_mask) &&
- !needed_by_vfsmount(test_mask, data, data_is))
+ !needed_by_vfsmount(test_mask, mnt))
return;
/*
@@ -214,16 +213,16 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
if (test_mask & to_tell->i_fsnotify_mask) {
list_for_each_entry_rcu(group, &fsnotify_inode_groups, inode_group_list) {
if (test_mask & group->mask) {
- send_to_group(mask, group, data, data_is,
- file_name, cookie, &event, to_tell);
+ send_to_group(group, to_tell, NULL, mask, data, data_is,
+ cookie, file_name, &event);
}
}
}
- if (needed_by_vfsmount(test_mask, data, data_is)) {
+ if (needed_by_vfsmount(test_mask, mnt)) {
list_for_each_entry_rcu(group, &fsnotify_vfsmount_groups, vfsmount_group_list) {
if (test_mask & group->mask) {
- send_to_group(mask, group, data, data_is,
- file_name, cookie, &event, to_tell);
+ send_to_group(group, to_tell, mnt, mask, data, data_is,
+ cookie, file_name, &event);
}
}
}