fsnotify: remove .should_send_event callback
authorJan Kara <jack@suse.cz>
Tue, 21 Jan 2014 23:48:15 +0000 (15:48 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 22 Jan 2014 00:19:41 +0000 (16:19 -0800)
After removing event structure creation from the generic layer there is
no reason for separate .should_send_event and .handle_event callbacks.
So just remove the first one.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Eric Paris <eparis@parisplace.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/notify/dnotify/dnotify.c
fs/notify/fanotify/fanotify.c
fs/notify/fsnotify.c
fs/notify/inotify/inotify_fsnotify.c
include/linux/fsnotify_backend.h
kernel/audit_tree.c
kernel/audit_watch.c

index bfca53dbbf34c0ccc5cf023894b43b1940029881..928688e3ee2f860cffc428cf396ae67fe7bbcea2 100644 (file)
@@ -94,6 +94,10 @@ static int dnotify_handle_event(struct fsnotify_group *group,
        struct fown_struct *fown;
        __u32 test_mask = mask & ~FS_EVENT_ON_CHILD;
 
+       /* not a dir, dnotify doesn't care */
+       if (!S_ISDIR(inode->i_mode))
+               return 0;
+
        BUG_ON(vfsmount_mark);
 
        dn_mark = container_of(inode_mark, struct dnotify_mark, fsn_mark);
@@ -121,23 +125,6 @@ static int dnotify_handle_event(struct fsnotify_group *group,
        return 0;
 }
 
-/*
- * Given an inode and mask determine if dnotify would be interested in sending
- * userspace notification for that pair.
- */
-static bool dnotify_should_send_event(struct fsnotify_group *group,
-                                     struct inode *inode,
-                                     struct fsnotify_mark *inode_mark,
-                                     struct fsnotify_mark *vfsmount_mark,
-                                     __u32 mask, void *data, int data_type)
-{
-       /* not a dir, dnotify doesn't care */
-       if (!S_ISDIR(inode->i_mode))
-               return false;
-
-       return true;
-}
-
 static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
 {
        struct dnotify_mark *dn_mark = container_of(fsn_mark,
@@ -151,7 +138,6 @@ static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
 
 static struct fsnotify_ops dnotify_fsnotify_ops = {
        .handle_event = dnotify_handle_event,
-       .should_send_event = dnotify_should_send_event,
        .free_group_priv = NULL,
        .freeing_mark = NULL,
        .free_event = NULL,
index c26268d7bd9dc0a16765d91784baa620f987967b..1f8f05220f8dd72aa6d8c00a792280084924ae45 100644 (file)
@@ -88,18 +88,17 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
 }
 #endif
 
-static bool fanotify_should_send_event(struct fsnotify_group *group,
-                                      struct inode *inode,
-                                      struct fsnotify_mark *inode_mark,
+static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
                                       struct fsnotify_mark *vfsmnt_mark,
-                                      __u32 event_mask, void *data, int data_type)
+                                      u32 event_mask,
+                                      void *data, int data_type)
 {
        __u32 marks_mask, marks_ignored_mask;
        struct path *path = data;
 
-       pr_debug("%s: group=%p inode=%p inode_mark=%p vfsmnt_mark=%p "
-                "mask=%x data=%p data_type=%d\n", __func__, group, inode,
-                inode_mark, vfsmnt_mark, event_mask, data, data_type);
+       pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p"
+                " data_type=%d\n", __func__, inode_mark, vfsmnt_mark,
+                event_mask, data, data_type);
 
        /* if we don't have enough info to send an event to userspace say no */
        if (data_type != FSNOTIFY_EVENT_PATH)
@@ -163,6 +162,10 @@ static int fanotify_handle_event(struct fsnotify_group *group,
        BUILD_BUG_ON(FAN_ACCESS_PERM != FS_ACCESS_PERM);
        BUILD_BUG_ON(FAN_ONDIR != FS_ISDIR);
 
+       if (!fanotify_should_send_event(inode_mark, fanotify_mark, mask, data,
+                                       data_type))
+               return 0;
+
        pr_debug("%s: group=%p inode=%p mask=%x\n", __func__, group, inode,
                 mask);
 
@@ -225,7 +228,6 @@ static void fanotify_free_event(struct fsnotify_event *fsn_event)
 
 const struct fsnotify_ops fanotify_fsnotify_ops = {
        .handle_event = fanotify_handle_event,
-       .should_send_event = fanotify_should_send_event,
        .free_group_priv = fanotify_free_group_priv,
        .free_event = fanotify_free_event,
        .freeing_mark = NULL,
index 7c754c91c3f6e21091d22c8d8e09264d018c0559..1d4e1ea2f37ca4995db3f16db9bd00bbf862ca93 100644 (file)
@@ -177,11 +177,6 @@ static int send_to_group(struct inode *to_tell,
        if (!inode_test_mask && !vfsmount_test_mask)
                return 0;
 
-       if (group->ops->should_send_event(group, to_tell, inode_mark,
-                                         vfsmount_mark, mask, data,
-                                         data_is) == false)
-               return 0;
-
        return group->ops->handle_event(group, to_tell, inode_mark,
                                        vfsmount_mark, mask, data, data_is,
                                        file_name);
index 6fabbd163d16b0f40931637f4233638cd52478bf..aad1a35e9af117fdc397cca897ba6f192f2de7a0 100644 (file)
@@ -81,6 +81,13 @@ int inotify_handle_event(struct fsnotify_group *group,
 
        BUG_ON(vfsmount_mark);
 
+       if ((inode_mark->mask & FS_EXCL_UNLINK) &&
+           (data_type == FSNOTIFY_EVENT_PATH)) {
+               struct path *path = data;
+
+               if (d_unlinked(path->dentry))
+                       return 0;
+       }
        if (file_name) {
                len = strlen(file_name);
                alloc_len += len + 1;
@@ -122,22 +129,6 @@ static void inotify_freeing_mark(struct fsnotify_mark *fsn_mark, struct fsnotify
        inotify_ignored_and_remove_idr(fsn_mark, group);
 }
 
-static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode,
-                                     struct fsnotify_mark *inode_mark,
-                                     struct fsnotify_mark *vfsmount_mark,
-                                     __u32 mask, void *data, int data_type)
-{
-       if ((inode_mark->mask & FS_EXCL_UNLINK) &&
-           (data_type == FSNOTIFY_EVENT_PATH)) {
-               struct path *path = data;
-
-               if (d_unlinked(path->dentry))
-                       return false;
-       }
-
-       return true;
-}
-
 /*
  * This is NEVER supposed to be called.  Inotify marks should either have been
  * removed from the idr when the watch was removed or in the
@@ -189,7 +180,6 @@ static void inotify_free_event(struct fsnotify_event *fsn_event)
 
 const struct fsnotify_ops inotify_fsnotify_ops = {
        .handle_event = inotify_handle_event,
-       .should_send_event = inotify_should_send_event,
        .free_group_priv = inotify_free_group_priv,
        .free_event = inotify_free_event,
        .freeing_mark = inotify_freeing_mark,
index 7f3d7dcfcd009251c1af3283e51f007a0fff9cca..7d8d5e608594c911c2eacc78dbb094c5384fd4af 100644 (file)
@@ -94,10 +94,6 @@ struct fsnotify_fname;
  *             userspace messages that marks have been removed.
  */
 struct fsnotify_ops {
-       bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode,
-                                 struct fsnotify_mark *inode_mark,
-                                 struct fsnotify_mark *vfsmount_mark,
-                                 __u32 mask, void *data, int data_type);
        int (*handle_event)(struct fsnotify_group *group,
                            struct inode *inode,
                            struct fsnotify_mark *inode_mark,
index bcc0b1821227e0dd08dbff4a5af8cb6d46abf71d..ae8103b057fa6e957ae977fc1c20ccafef884d2f 100644 (file)
@@ -918,8 +918,7 @@ static int audit_tree_handle_event(struct fsnotify_group *group,
                                   u32 mask, void *data, int data_type,
                                   const unsigned char *file_name)
 {
-       BUG();
-       return -EOPNOTSUPP;
+       return 0;
 }
 
 static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify_group *group)
@@ -935,17 +934,8 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify
        BUG_ON(atomic_read(&entry->refcnt) < 1);
 }
 
-static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode,
-                                 struct fsnotify_mark *inode_mark,
-                                 struct fsnotify_mark *vfsmount_mark,
-                                 __u32 mask, void *data, int data_type)
-{
-       return false;
-}
-
 static const struct fsnotify_ops audit_tree_ops = {
        .handle_event = audit_tree_handle_event,
-       .should_send_event = audit_tree_send_event,
        .free_group_priv = NULL,
        .free_event = NULL,
        .freeing_mark = audit_tree_freeing_mark,
index a760c32cb6399bd937585c362e9670afe073e8ae..367ac9a79acc707673a0a8b647ab3e8a6b843980 100644 (file)
@@ -465,14 +465,6 @@ void audit_remove_watch_rule(struct audit_krule *krule)
        }
 }
 
-static bool audit_watch_should_send_event(struct fsnotify_group *group, struct inode *inode,
-                                         struct fsnotify_mark *inode_mark,
-                                         struct fsnotify_mark *vfsmount_mark,
-                                         __u32 mask, void *data, int data_type)
-{
-       return true;
-}
-
 /* Update watch data in audit rules based on fsnotify events. */
 static int audit_watch_handle_event(struct fsnotify_group *group,
                                    struct inode *to_tell,
@@ -512,7 +504,6 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
 }
 
 static const struct fsnotify_ops audit_watch_fsnotify_ops = {
-       .should_send_event =    audit_watch_should_send_event,
        .handle_event =         audit_watch_handle_event,
        .free_group_priv =      NULL,
        .freeing_mark =         NULL,