]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/notify/fanotify/fanotify.c
fanotify: use the mark in handler functions
[net-next-2.6.git] / fs / notify / fanotify / fanotify.c
index f3c40c0e2b867c0ee7f552a034a506c741f3c015..666ccb733066ecefd1c0bd8bc4a242ced72f9d79 100644 (file)
@@ -17,9 +17,9 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
            old->data_type == new->data_type &&
            old->tgid == new->tgid) {
                switch (old->data_type) {
-               case (FSNOTIFY_EVENT_PATH):
-                       if ((old->path.mnt == new->path.mnt) &&
-                           (old->path.dentry == new->path.dentry))
+               case (FSNOTIFY_EVENT_FILE):
+                       if ((old->file->f_path.mnt == new->file->f_path.mnt) &&
+                           (old->file->f_path.dentry == new->file->f_path.dentry))
                                return true;
                case (FSNOTIFY_EVENT_NONE):
                        return true;
@@ -114,7 +114,9 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
 }
 #endif
 
-static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
+static int fanotify_handle_event(struct fsnotify_group *group,
+                                struct fsnotify_mark *mark,
+                                struct fsnotify_event *event)
 {
        int ret = 0;
        struct fsnotify_event *notify_event = NULL;
@@ -150,18 +152,16 @@ static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_e
        return ret;
 }
 
-static bool should_send_vfsmount_event(struct fsnotify_group *group, struct vfsmount *mnt,
-                                      struct inode *inode, __u32 mask)
+static bool should_send_vfsmount_event(struct fsnotify_group *group,
+                                      struct vfsmount *mnt,
+                                      struct inode *inode,
+                                      struct fsnotify_mark *mnt_mark,
+                                      __u32 mask)
 {
-       struct fsnotify_mark *mnt_mark;
        struct fsnotify_mark *inode_mark;
 
-       pr_debug("%s: group=%p vfsmount=%p mask=%x\n",
-                __func__, group, mnt, mask);
-
-       mnt_mark = fsnotify_find_vfsmount_mark(group, mnt);
-       if (!mnt_mark)
-               return false;
+       pr_debug("%s: group=%p vfsmount=%p mark=%p mask=%x\n",
+                __func__, group, mnt, mnt_mark, mask);
 
        mask &= mnt_mark->mask;
        mask &= ~mnt_mark->ignored_mask;
@@ -174,28 +174,21 @@ static bool should_send_vfsmount_event(struct fsnotify_group *group, struct vfsm
                }
        }
 
-       /* find took a reference */
-       fsnotify_put_mark(mnt_mark);
-
        return mask;
 }
 
-static bool should_send_inode_event(struct fsnotify_group *group, struct inode *inode,
+static bool should_send_inode_event(struct fsnotify_group *group,
+                                   struct inode *inode,
+                                   struct fsnotify_mark *mark,
                                    __u32 mask)
 {
-       struct fsnotify_mark *fsn_mark;
-
-       pr_debug("%s: group=%p inode=%p mask=%x\n",
-                __func__, group, inode, mask);
-
-       fsn_mark = fsnotify_find_inode_mark(group, inode);
-       if (!fsn_mark)
-               return false;
+       pr_debug("%s: group=%p inode=%p mark=%p mask=%x\n",
+                __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) &&
-           !(fsn_mark->mask & FS_EVENT_ON_CHILD)) {
+           !(mark->mask & FS_EVENT_ON_CHILD)) {
                mask = 0;
        } else {
                /*
@@ -203,19 +196,16 @@ static bool should_send_inode_event(struct fsnotify_group *group, struct inode *
                 * type of event?
                 */
                mask &= ~FS_EVENT_ON_CHILD;
-               mask &= fsn_mark->mask;
-               mask &= ~fsn_mark->ignored_mask;
+               mask &= mark->mask;
+               mask &= ~mark->ignored_mask;
        }
 
-       /* find took a reference */
-       fsnotify_put_mark(fsn_mark);
-
        return mask;
 }
 
 static bool fanotify_should_send_event(struct fsnotify_group *group, struct inode *to_tell,
-                                      struct vfsmount *mnt, __u32 mask, void *data,
-                                      int data_type)
+                                      struct vfsmount *mnt, struct fsnotify_mark *mark,
+                                      __u32 mask, void *data, int data_type)
 {
        pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x data=%p data_type=%d\n",
                 __func__, group, to_tell, mnt, mask, data, data_type);
@@ -226,13 +216,13 @@ static bool fanotify_should_send_event(struct fsnotify_group *group, struct inod
                return false;
 
        /* if we don't have enough info to send an event to userspace say no */
-       if (data_type != FSNOTIFY_EVENT_PATH)
+       if (data_type != FSNOTIFY_EVENT_FILE)
                return false;
 
        if (mnt)
-               return should_send_vfsmount_event(group, mnt, to_tell, mask);
+               return should_send_vfsmount_event(group, mnt, to_tell, mark, mask);
        else
-               return should_send_inode_event(group, to_tell, mask);
+               return should_send_inode_event(group, to_tell, mark, mask);
 }
 
 const struct fsnotify_ops fanotify_fsnotify_ops = {