fanotify: generalize fanotify_should_send_event()

Use fsnotify_foreach_obj_type macros to generalize the code that filters
events by marks mask and ignored_mask.

This is going to be used for adding mark of super block object type.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by Amir Goldstein and committed by Jan Kara 837a3934 3dca1a74

Changed files
+18 -18
fs
notify
fanotify
+18 -18
fs/notify/fanotify/fanotify.c
··· 91 91 u32 event_mask, const void *data, 92 92 int data_type) 93 93 { 94 - struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 95 - struct fsnotify_mark *vfsmnt_mark = fsnotify_iter_vfsmount_mark(iter_info); 96 94 __u32 marks_mask = 0, marks_ignored_mask = 0; 97 95 const struct path *path = data; 96 + struct fsnotify_mark *mark; 97 + int type; 98 98 99 - pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p" 100 - " data_type=%d\n", __func__, inode_mark, vfsmnt_mark, 101 - event_mask, data, data_type); 99 + pr_debug("%s: report_mask=%x mask=%x data=%p data_type=%d\n", 100 + __func__, iter_info->report_mask, event_mask, data, data_type); 102 101 103 102 /* if we don't have enough info to send an event to userspace say no */ 104 103 if (data_type != FSNOTIFY_EVENT_PATH) ··· 108 109 !d_can_lookup(path->dentry)) 109 110 return false; 110 111 111 - /* 112 - * if the event is for a child and this inode doesn't care about 113 - * events on the child, don't send it! 114 - */ 115 - if (inode_mark && 116 - (!(event_mask & FS_EVENT_ON_CHILD) || 117 - (inode_mark->mask & FS_EVENT_ON_CHILD))) { 118 - marks_mask |= inode_mark->mask; 119 - marks_ignored_mask |= inode_mark->ignored_mask; 120 - } 112 + fsnotify_foreach_obj_type(type) { 113 + if (!fsnotify_iter_should_report_type(iter_info, type)) 114 + continue; 115 + mark = iter_info->marks[type]; 116 + /* 117 + * if the event is for a child and this inode doesn't care about 118 + * events on the child, don't send it! 119 + */ 120 + if (type == FSNOTIFY_OBJ_TYPE_INODE && 121 + (event_mask & FS_EVENT_ON_CHILD) && 122 + !(mark->mask & FS_EVENT_ON_CHILD)) 123 + continue; 121 124 122 - if (vfsmnt_mark) { 123 - marks_mask |= vfsmnt_mark->mask; 124 - marks_ignored_mask |= vfsmnt_mark->ignored_mask; 125 + marks_mask |= mark->mask; 126 + marks_ignored_mask |= mark->ignored_mask; 125 127 } 126 128 127 129 if (d_is_dir(path->dentry) &&