aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2010-07-28 10:18:38 -0400
committerEric Paris <eparis@redhat.com>2010-07-28 10:18:52 -0400
commit3a9b16b407f10b2a771bcae13fb5791e527d6bcf (patch)
tree0d88cac61bd6d3f5028eb0c9a45e7af9fbd24311
parent8778abb9a88fc4a74d8776ffaadf7214cf33c61e (diff)
fsnotify: send fsnotify_mark to groups in event handling functions
With the change of fsnotify to use srcu walking the marks list instead of walking the global groups list we now know the mark in question. The code can send the mark to the group's handling functions and the groups won't have to find those marks themselves. Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r--fs/notify/dnotify/dnotify.c4
-rw-r--r--fs/notify/fanotify/fanotify.c8
-rw-r--r--fs/notify/fsnotify.c19
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c8
-rw-r--r--include/linux/fsnotify_backend.h7
-rw-r--r--kernel/audit_tree.c8
-rw-r--r--kernel/audit_watch.c8
7 files changed, 37 insertions, 25 deletions
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index 6624c2ee8786..2cae9be120db 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -83,6 +83,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
83 * events. 83 * events.
84 */ 84 */
85static int dnotify_handle_event(struct fsnotify_group *group, 85static int dnotify_handle_event(struct fsnotify_group *group,
86 struct fsnotify_mark *mark,
86 struct fsnotify_event *event) 87 struct fsnotify_event *event)
87{ 88{
88 struct fsnotify_mark *fsn_mark = NULL; 89 struct fsnotify_mark *fsn_mark = NULL;
@@ -130,7 +131,8 @@ static int dnotify_handle_event(struct fsnotify_group *group,
130 */ 131 */
131static bool dnotify_should_send_event(struct fsnotify_group *group, 132static bool dnotify_should_send_event(struct fsnotify_group *group,
132 struct inode *inode, struct vfsmount *mnt, 133 struct inode *inode, struct vfsmount *mnt,
133 __u32 mask, void *data, int data_type) 134 struct fsnotify_mark *mark, __u32 mask,
135 void *data, int data_type)
134{ 136{
135 struct fsnotify_mark *fsn_mark; 137 struct fsnotify_mark *fsn_mark;
136 bool send; 138 bool send;
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index c2a3029052bc..abfba45abe2c 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -114,7 +114,9 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
114} 114}
115#endif 115#endif
116 116
117static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) 117static int fanotify_handle_event(struct fsnotify_group *group,
118 struct fsnotify_mark *mark,
119 struct fsnotify_event *event)
118{ 120{
119 int ret = 0; 121 int ret = 0;
120 struct fsnotify_event *notify_event = NULL; 122 struct fsnotify_event *notify_event = NULL;
@@ -214,8 +216,8 @@ static bool should_send_inode_event(struct fsnotify_group *group, struct inode *
214} 216}
215 217
216static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell, 218static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
217 struct vfsmount *mnt, __u32 mask, void *data, 219 struct vfsmount *mnt, struct fsnotify_mark *mark,
218 int data_type) 220 __u32 mask, void *data, int data_type)
219{ 221{
220 pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n", 222 pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n",
221 __func__, group, to_tell, mnt, mask, data, data_type); 223 __func__, group, to_tell, mnt, mask, data, data_type);
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 4678b416241e..59d639996cad 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -171,15 +171,16 @@ void __fsnotify_flush_ignored_mask(struct inode *inode, void *data, int data_is)
171} 171}
172 172
173static int send_to_group(struct fsnotify_group *group, struct inode *to_tell, 173static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
174 struct vfsmount *mnt, __u32 mask, void *data, 174 struct vfsmount *mnt, struct fsnotify_mark *mark,
175 int data_is, u32 cookie, const unsigned char *file_name, 175 __u32 mask, void *data, int data_is, u32 cookie,
176 const unsigned char *file_name,
176 struct fsnotify_event **event) 177 struct fsnotify_event **event)
177{ 178{
178 pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_is=%d" 179 pr_debug("%s: group=%p to_tell=%p mnt=%p mark=%p mask=%x data=%p"
179 " cookie=%d event=%p\n", __func__, group, to_tell, mnt, 180 " data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
180 mask, data, data_is, cookie, *event); 181 mnt, mark, mask, data, data_is, cookie, *event);
181 182
182 if (!group->ops->should_send_event(group, to_tell, mnt, mask, 183 if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
183 data, data_is)) 184 data, data_is))
184 return 0; 185 return 0;
185 if (!*event) { 186 if (!*event) {
@@ -189,7 +190,7 @@ static int send_to_group(struct fsnotify_group *group, struct inode *to_tell,
189 if (!*event) 190 if (!*event)
190 return -ENOMEM; 191 return -ENOMEM;
191 } 192 }
192 return group->ops->handle_event(group, *event); 193 return group->ops->handle_event(group, mark, *event);
193} 194}
194 195
195static bool needed_by_vfsmount(__u32 test_mask, struct vfsmount *mnt) 196static bool needed_by_vfsmount(__u32 test_mask, struct vfsmount *mnt)
@@ -252,7 +253,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
252 group = mark->group; 253 group = mark->group;
253 if (!group) 254 if (!group)
254 continue; 255 continue;
255 ret = send_to_group(group, to_tell, NULL, mask, 256 ret = send_to_group(group, to_tell, NULL, mark, mask,
256 data, data_is, cookie, file_name, 257 data, data_is, cookie, file_name,
257 &event); 258 &event);
258 if (ret) 259 if (ret)
@@ -271,7 +272,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
271 group = mark->group; 272 group = mark->group;
272 if (!group) 273 if (!group)
273 continue; 274 continue;
274 ret = send_to_group(group, to_tell, mnt, mask, 275 ret = send_to_group(group, to_tell, mnt, mark, mask,
275 data, data_is, cookie, file_name, 276 data, data_is, cookie, file_name,
276 &event); 277 &event);
277 if (ret) 278 if (ret)
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index 3c506e0364cc..dbd76bbb3e21 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -89,7 +89,9 @@ static struct fsnotify_event *inotify_merge(struct list_head *list,
89 return last_event; 89 return last_event;
90} 90}
91 91
92static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) 92static int inotify_handle_event(struct fsnotify_group *group,
93 struct fsnotify_mark *mark,
94 struct fsnotify_event *event)
93{ 95{
94 struct fsnotify_mark *fsn_mark; 96 struct fsnotify_mark *fsn_mark;
95 struct inotify_inode_mark *i_mark; 97 struct inotify_inode_mark *i_mark;
@@ -148,8 +150,8 @@ static void inotify_freeing_mark(struct fsnotify_mark *fsn_mark, struct fsnotify
148} 150}
149 151
150static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode, 152static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode,
151 struct vfsmount *mnt, __u32 mask, void *data, 153 struct vfsmount *mnt, struct fsnotify_mark *mark,
152 int data_type) 154 __u32 mask, void *data, int data_type)
153{ 155{
154 struct fsnotify_mark *fsn_mark; 156 struct fsnotify_mark *fsn_mark;
155 bool send; 157 bool send;
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 84159390969f..225dc0c3a48c 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -92,9 +92,10 @@ struct fsnotify_event_private_data;
92 */ 92 */
93struct fsnotify_ops { 93struct fsnotify_ops {
94 bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode, 94 bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode,
95 struct vfsmount *mnt, __u32 mask, void *data, 95 struct vfsmount *mnt, struct fsnotify_mark *mark,
96 int data_type); 96 __u32 mask, void *data, int data_type);
97 int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event); 97 int (*handle_event)(struct fsnotify_group *group, struct fsnotify_mark *mark,
98 struct fsnotify_event *event);
98 void (*free_group_priv)(struct fsnotify_group *group); 99 void (*free_group_priv)(struct fsnotify_group *group);
99 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group); 100 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
100 void (*free_event_priv)(struct fsnotify_event_private_data *priv); 101 void (*free_event_priv)(struct fsnotify_event_private_data *priv);
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index cfb97d752a61..584b94360217 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -903,7 +903,9 @@ static void evict_chunk(struct audit_chunk *chunk)
903 mutex_unlock(&audit_filter_mutex); 903 mutex_unlock(&audit_filter_mutex);
904} 904}
905 905
906static int audit_tree_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) 906static int audit_tree_handle_event(struct fsnotify_group *group,
907 struct fsnotify_mark *mark,
908 struct fsnotify_event *event)
907{ 909{
908 BUG(); 910 BUG();
909 return -EOPNOTSUPP; 911 return -EOPNOTSUPP;
@@ -918,8 +920,8 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify
918} 920}
919 921
920static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode, 922static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode,
921 struct vfsmount *mnt, __u32 mask, void *data, 923 struct vfsmount *mnt, struct fsnotify_mark *mark,
922 int data_type) 924 __u32 mask, void *data, int data_type)
923{ 925{
924 return 0; 926 return 0;
925} 927}
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index b955a22d8ff1..4d5ea0319a6c 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -511,8 +511,8 @@ void audit_remove_watch_rule(struct audit_krule *krule)
511} 511}
512 512
513static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode, 513static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode,
514 struct vfsmount *mnt, __u32 mask, void *data, 514 struct vfsmount *mnt, struct fsnotify_mark *mark,
515 int data_type) 515 __u32 mask, void *data, int data_type)
516{ 516{
517 struct fsnotify_mark *entry; 517 struct fsnotify_mark *entry;
518 bool send; 518 bool send;
@@ -531,7 +531,9 @@ static bool audit_watch_should_send_event(struct fsnotify_group *group, struct i
531} 531}
532 532
533/* Update watch data in audit rules based on fsnotify events. */ 533/* Update watch data in audit rules based on fsnotify events. */
534static int audit_watch_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) 534static int audit_watch_handle_event(struct fsnotify_group *group,
535 struct fsnotify_mark *mark,
536 struct fsnotify_event *event)
535{ 537{
536 struct inode *inode; 538 struct inode *inode;
537 __u32 mask = event->mask; 539 __u32 mask = event->mask;