Common fsnotify_event helpers have no need for the mask field.
It is only used by backend code, so move the field out of the
abstract fsnotify_event struct and into the concrete backend
event structs.
This change packs struct inotify_event_info better on 64bit
machine and will allow us to cram some more fields into
struct fanotify_event_info.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
 static int fanotify_merge(struct list_head *list, struct fsnotify_event *event)
 {
        struct fsnotify_event *test_event;
+       struct fanotify_event_info *new;
 
        pr_debug("%s: list=%p event=%p\n", __func__, list, event);
+       new = FANOTIFY_E(event);
 
        /*
         * Don't merge a permission event with any other event so that we know
         * the event structure we have created in fanotify_handle_event() is the
         * one we should check for permission response.
         */
-       if (fanotify_is_perm_event(event->mask))
+       if (fanotify_is_perm_event(new->mask))
                return 0;
 
        list_for_each_entry_reverse(test_event, list, list) {
                if (should_merge(test_event, event)) {
-                       test_event->mask |= event->mask;
+                       FANOTIFY_E(test_event)->mask |= new->mask;
                        return 1;
                }
        }
        if (!event)
                goto out;
 init: __maybe_unused
-       fsnotify_init_event(&event->fse, inode, mask);
+       fsnotify_init_event(&event->fse, inode);
+       event->mask = mask;
        if (FAN_GROUP_FLAG(group, FAN_REPORT_TID))
                event->pid = get_pid(task_pid(current));
        else
        event = FANOTIFY_E(fsn_event);
        path_put(&event->path);
        put_pid(event->pid);
-       if (fanotify_is_perm_event(fsn_event->mask)) {
+       if (fanotify_is_perm_event(event->mask)) {
                kmem_cache_free(fanotify_perm_event_cachep,
                                FANOTIFY_PE(fsn_event));
                return;
 
  */
 struct fanotify_event_info {
        struct fsnotify_event fse;
+       u32 mask;
        /*
         * We hold ref to this path so it may be dereferenced at any point
         * during this object's lifetime
 
        metadata->metadata_len = FAN_EVENT_METADATA_LEN;
        metadata->vers = FANOTIFY_METADATA_VERSION;
        metadata->reserved = 0;
-       metadata->mask = fsn_event->mask & FANOTIFY_OUTGOING_EVENTS;
+       metadata->mask = event->mask & FANOTIFY_OUTGOING_EVENTS;
        metadata->pid = pid_vnr(event->pid);
-       if (unlikely(fsn_event->mask & FAN_Q_OVERFLOW))
+       if (unlikely(event->mask & FAN_Q_OVERFLOW))
                metadata->fd = FAN_NOFD;
        else {
                metadata->fd = create_fd(group, event, file);
                         fanotify_event_metadata.event_len))
                goto out_close_fd;
 
-       if (fanotify_is_perm_event(event->mask))
+       if (fanotify_is_perm_event(FANOTIFY_E(event)->mask))
                FANOTIFY_PE(event)->fd = fd;
 
        if (fd != FAN_NOFD)
                 * Permission events get queued to wait for response.  Other
                 * events can be destroyed now.
                 */
-               if (!fanotify_is_perm_event(kevent->mask)) {
+               if (!fanotify_is_perm_event(FANOTIFY_E(kevent)->mask)) {
                        fsnotify_destroy_event(group, kevent);
                } else {
                        if (ret <= 0) {
         */
        while (!fsnotify_notify_queue_is_empty(group)) {
                fsn_event = fsnotify_remove_first_event(group);
-               if (!(fsn_event->mask & FANOTIFY_PERM_EVENTS)) {
+               if (!(FANOTIFY_E(fsn_event)->mask & FANOTIFY_PERM_EVENTS)) {
                        spin_unlock(&group->notification_lock);
                        fsnotify_destroy_event(group, fsn_event);
                        spin_lock(&group->notification_lock);
 
 
 struct inotify_event_info {
        struct fsnotify_event fse;
+       u32 mask;
        int wd;
        u32 sync_cookie;
        int name_len;
 
 {
        struct inotify_event_info *old, *new;
 
-       if (old_fsn->mask & FS_IN_IGNORED)
-               return false;
        old = INOTIFY_E(old_fsn);
        new = INOTIFY_E(new_fsn);
-       if ((old_fsn->mask == new_fsn->mask) &&
+       if (old->mask & FS_IN_IGNORED)
+               return false;
+       if ((old->mask == new->mask) &&
            (old_fsn->inode == new_fsn->inode) &&
            (old->name_len == new->name_len) &&
            (!old->name_len || !strcmp(old->name, new->name)))
        }
 
        fsn_event = &event->fse;
-       fsnotify_init_event(fsn_event, inode, mask);
+       fsnotify_init_event(fsn_event, inode);
+       event->mask = mask;
        event->wd = i_mark->wd;
        event->sync_cookie = cookie;
        event->name_len = len;
 
         */
        pad_name_len = round_event_name_len(fsn_event);
        inotify_event.len = pad_name_len;
-       inotify_event.mask = inotify_mask_to_arg(fsn_event->mask);
+       inotify_event.mask = inotify_mask_to_arg(event->mask);
        inotify_event.wd = event->wd;
        inotify_event.cookie = event->sync_cookie;
 
                return ERR_PTR(-ENOMEM);
        }
        group->overflow_event = &oevent->fse;
-       fsnotify_init_event(group->overflow_event, NULL, FS_Q_OVERFLOW);
+       fsnotify_init_event(group->overflow_event, NULL);
+       oevent->mask = FS_Q_OVERFLOW;
        oevent->wd = -1;
        oevent->sync_cookie = 0;
        oevent->name_len = 0;
 
                            struct fsnotify_event *event)
 {
        /* Overflow events are per-group and we don't want to free them */
-       if (!event || event->mask == FS_Q_OVERFLOW)
+       if (!event || event == group->overflow_event)
                return;
        /*
         * If the event is still queued, we have a problem... Do an unreliable
        }
        spin_unlock(&group->notification_lock);
 }
-
-/*
- * fsnotify_create_event - Allocate a new event which will be sent to each
- * group's handle_event function if the group was interested in this
- * particular event.
- *
- * @inode the inode which is supposed to receive the event (sometimes a
- *     parent of the inode to which the event happened.
- * @mask what actually happened.
- * @data pointer to the object which was actually affected
- * @data_type flag indication if the data is a file, path, inode, nothing...
- * @name the filename, if available
- */
-void fsnotify_init_event(struct fsnotify_event *event, struct inode *inode,
-                        u32 mask)
-{
-       INIT_LIST_HEAD(&event->list);
-       event->inode = inode;
-       event->mask = mask;
-}
 
        struct list_head list;
        /* inode may ONLY be dereferenced during handle_event(). */
        struct inode *inode;    /* either the inode the event happened to or its parent */
-       u32 mask;               /* the type of access, bitwise OR for FS_* event types */
 };
 
 /*
 extern void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info);
 extern bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info);
 
-/* put here because inotify does some weird stuff when destroying watches */
-extern void fsnotify_init_event(struct fsnotify_event *event,
-                               struct inode *to_tell, u32 mask);
+static inline void fsnotify_init_event(struct fsnotify_event *event,
+                                      struct inode *inode)
+{
+       INIT_LIST_HEAD(&event->list);
+       event->inode = inode;
+}
 
 #else