Commit 2612abb51b11ffd2d75c472b11178115f5808909

Authored by Eric Paris
1 parent 0215054f37

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>

Showing 6 changed files with 16 additions and 45 deletions Side-by-side Diff

fs/notify/dnotify/dnotify.c
... ... @@ -129,20 +129,11 @@
129 129 struct fsnotify_mark *mark, __u32 mask,
130 130 void *data, int data_type)
131 131 {
132   - bool send;
133   -
134   - /* !dir_notify_enable should never get here, don't waste time checking
135   - if (!dir_notify_enable)
136   - return 0; */
137   -
138 132 /* not a dir, dnotify doesn't care */
139 133 if (!S_ISDIR(inode->i_mode))
140 134 return false;
141 135  
142   - mask = (mask & ~FS_EVENT_ON_CHILD);
143   - send = (mask & mark->mask);
144   -
145   - return send;
  136 + return true;
146 137 }
147 138  
148 139 static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
fs/notify/fanotify/fanotify.c
... ... @@ -185,22 +185,15 @@
185 185 pr_debug("%s: group=%p inode=%p mark=%p mask=%x\n",
186 186 __func__, group, inode, mark, mask);
187 187  
188   - /* if the event is for a child and this inode doesn't care about
189   - * events on the child, don't send it! */
  188 + /*
  189 + * if the event is for a child and this inode doesn't care about
  190 + * events on the child, don't send it!
  191 + */
190 192 if ((mask & FS_EVENT_ON_CHILD) &&
191   - !(mark->mask & FS_EVENT_ON_CHILD)) {
192   - mask = 0;
193   - } else {
194   - /*
195   - * We care about children, but do we care about this particular
196   - * type of event?
197   - */
198   - mask &= ~FS_EVENT_ON_CHILD;
199   - mask &= mark->mask;
200   - mask &= ~mark->ignored_mask;
201   - }
202   -
203   - return mask;
  193 + !(mark->mask & FS_EVENT_ON_CHILD))
  194 + return false;
  195 + else
  196 + return true;
204 197 }
205 198  
206 199 static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
fs/notify/fsnotify.c
... ... @@ -180,8 +180,8 @@
180 180 " data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
181 181 mnt, mark, mask, data, data_is, cookie, *event);
182 182  
183   - if (!group->ops->should_send_event(group, to_tell, mnt, mark, mask,
184   - data, data_is))
  183 + if (group->ops->should_send_event(group, to_tell, mnt, mark, mask,
  184 + data, data_is) == false)
185 185 return 0;
186 186 if (!*event) {
187 187 *event = fsnotify_create_event(to_tell, mask, data,
fs/notify/inotify/inotify_fsnotify.c
... ... @@ -142,23 +142,15 @@
142 142 struct vfsmount *mnt, struct fsnotify_mark *mark,
143 143 __u32 mask, void *data, int data_type)
144 144 {
145   - bool send;
146   -
147   - pr_debug("%s: group=%p inode=%p mask=%x data=%p data_type=%d\n",
148   - __func__, group, inode, mask, data, data_type);
149   -
150   - mask = (mask & ~FS_EVENT_ON_CHILD);
151   - send = (mark->mask & mask);
152   -
153   - if (send && (mark->mask & FS_EXCL_UNLINK) &&
  145 + if ((mark->mask & FS_EXCL_UNLINK) &&
154 146 (data_type == FSNOTIFY_EVENT_FILE)) {
155 147 struct file *file = data;
156 148  
157 149 if (d_unlinked(file->f_path.dentry))
158   - send = false;
  150 + return false;
159 151 }
160 152  
161   - return send;
  153 + return true;
162 154 }
163 155  
164 156 /*
... ... @@ -923,7 +923,7 @@
923 923 struct vfsmount *mnt, struct fsnotify_mark *mark,
924 924 __u32 mask, void *data, int data_type)
925 925 {
926   - return 0;
  926 + return false;
927 927 }
928 928  
929 929 static const struct fsnotify_ops audit_tree_ops = {
kernel/audit_watch.c
... ... @@ -514,12 +514,7 @@
514 514 struct vfsmount *mnt, struct fsnotify_mark *mark,
515 515 __u32 mask, void *data, int data_type)
516 516 {
517   - bool send;
518   -
519   - mask = (mask & ~FS_EVENT_ON_CHILD);
520   - send = (mark->mask & mask);
521   -
522   - return send;
  517 + return true;
523 518 }
524 519  
525 520 /* Update watch data in audit rules based on fsnotify events. */