Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fsnotify: remove redundant arguments to handle_event()

inode_mark and vfsmount_mark arguments are passed to handle_event()
operation as function arguments as well as on iter_info struct.
The difference is that iter_info struct may contain marks that should
not be handled and are represented as NULL arguments to inode_mark or
vfsmount_mark.

Instead of passing the inode_mark and vfsmount_mark arguments, add
a report_mask member to iter_info struct to indicate which marks should
be handled, versus marks that should only be kept alive during user
wait.

This change is going to be used for passing more mark types
with handle_event() (i.e. super block marks).

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
5b0457ad d6f7b98b

+58 -50
+3 -3
fs/notify/dnotify/dnotify.c
··· 79 79 */ 80 80 static int dnotify_handle_event(struct fsnotify_group *group, 81 81 struct inode *inode, 82 - struct fsnotify_mark *inode_mark, 83 - struct fsnotify_mark *vfsmount_mark, 84 82 u32 mask, const void *data, int data_type, 85 83 const unsigned char *file_name, u32 cookie, 86 84 struct fsnotify_iter_info *iter_info) 87 85 { 86 + struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 88 87 struct dnotify_mark *dn_mark; 89 88 struct dnotify_struct *dn; 90 89 struct dnotify_struct **prev; ··· 94 95 if (!S_ISDIR(inode->i_mode)) 95 96 return 0; 96 97 97 - BUG_ON(vfsmount_mark); 98 + if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info))) 99 + return 0; 98 100 99 101 dn_mark = container_of(inode_mark, struct dnotify_mark, fsn_mark); 100 102
+6 -8
fs/notify/fanotify/fanotify.c
··· 87 87 return ret; 88 88 } 89 89 90 - static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark, 91 - struct fsnotify_mark *vfsmnt_mark, 92 - u32 event_mask, 93 - const void *data, int data_type) 90 + static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info, 91 + u32 event_mask, const void *data, 92 + int data_type) 94 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); 95 96 __u32 marks_mask = 0, marks_ignored_mask = 0; 96 97 const struct path *path = data; 97 98 ··· 179 178 180 179 static int fanotify_handle_event(struct fsnotify_group *group, 181 180 struct inode *inode, 182 - struct fsnotify_mark *inode_mark, 183 - struct fsnotify_mark *fanotify_mark, 184 181 u32 mask, const void *data, int data_type, 185 182 const unsigned char *file_name, u32 cookie, 186 183 struct fsnotify_iter_info *iter_info) ··· 198 199 BUILD_BUG_ON(FAN_ACCESS_PERM != FS_ACCESS_PERM); 199 200 BUILD_BUG_ON(FAN_ONDIR != FS_ISDIR); 200 201 201 - if (!fanotify_should_send_event(inode_mark, fanotify_mark, mask, data, 202 - data_type)) 202 + if (!fanotify_should_send_event(iter_info, mask, data, data_type)) 203 203 return 0; 204 204 205 205 pr_debug("%s: group=%p inode=%p mask=%x\n", __func__, group, inode,
+20 -18
fs/notify/fsnotify.c
··· 184 184 EXPORT_SYMBOL_GPL(__fsnotify_parent); 185 185 186 186 static int send_to_group(struct inode *to_tell, 187 - struct fsnotify_mark *inode_mark, 188 - struct fsnotify_mark *vfsmount_mark, 189 187 __u32 mask, const void *data, 190 188 int data_is, u32 cookie, 191 189 const unsigned char *file_name, 192 190 struct fsnotify_iter_info *iter_info) 193 191 { 192 + struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 193 + struct fsnotify_mark *vfsmount_mark = fsnotify_iter_vfsmount_mark(iter_info); 194 194 struct fsnotify_group *group = NULL; 195 195 __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); 196 196 __u32 marks_mask = 0; 197 197 __u32 marks_ignored_mask = 0; 198 198 199 - if (unlikely(!inode_mark && !vfsmount_mark)) { 200 - BUG(); 199 + if (WARN_ON(!iter_info->report_mask)) 201 200 return 0; 202 - } 203 201 204 202 /* clear ignored on inode modification */ 205 203 if (mask & FS_MODIFY) { ··· 233 235 if (!(test_mask & marks_mask & ~marks_ignored_mask)) 234 236 return 0; 235 237 236 - return group->ops->handle_event(group, to_tell, inode_mark, 237 - vfsmount_mark, mask, data, data_is, 238 + return group->ops->handle_event(group, to_tell, mask, data, data_is, 238 239 file_name, cookie, iter_info); 239 240 } 240 241 ··· 324 327 while (iter_info.inode_mark || iter_info.vfsmount_mark) { 325 328 struct fsnotify_mark *inode_mark = iter_info.inode_mark; 326 329 struct fsnotify_mark *vfsmount_mark = iter_info.vfsmount_mark; 330 + int cmp; 327 331 328 332 if (inode_mark && vfsmount_mark) { 329 - int cmp = fsnotify_compare_groups(inode_mark->group, 330 - vfsmount_mark->group); 331 - if (cmp > 0) 332 - inode_mark = NULL; 333 - else if (cmp < 0) 334 - vfsmount_mark = NULL; 333 + cmp = fsnotify_compare_groups(inode_mark->group, 334 + vfsmount_mark->group); 335 + } else { 336 + cmp = inode_mark ? -1 : 1; 335 337 } 336 338 337 - ret = send_to_group(to_tell, inode_mark, vfsmount_mark, mask, 338 - data, data_is, cookie, file_name, 339 - &iter_info); 339 + iter_info.report_mask = 0; 340 + if (cmp <= 0) 341 + iter_info.report_mask |= FSNOTIFY_OBJ_TYPE_INODE_FL; 342 + if (cmp >= 0) 343 + iter_info.report_mask |= FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL; 344 + 345 + ret = send_to_group(to_tell, mask, data, data_is, cookie, 346 + file_name, &iter_info); 340 347 341 348 if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS)) 342 349 goto out; 343 350 344 - if (inode_mark) 351 + if (iter_info.report_mask & FSNOTIFY_OBJ_TYPE_INODE_FL) 345 352 iter_info.inode_mark = 346 353 fsnotify_next_mark(iter_info.inode_mark); 347 - if (vfsmount_mark) 354 + 355 + if (iter_info.report_mask & FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL) 348 356 iter_info.vfsmount_mark = 349 357 fsnotify_next_mark(iter_info.vfsmount_mark); 350 358 }
-6
fs/notify/fsnotify.h
··· 9 9 10 10 #include "../mount.h" 11 11 12 - struct fsnotify_iter_info { 13 - struct fsnotify_mark *inode_mark; 14 - struct fsnotify_mark *vfsmount_mark; 15 - int srcu_idx; 16 - }; 17 - 18 12 /* destroy all events sitting in this groups notification queue */ 19 13 extern void fsnotify_flush_notify(struct fsnotify_group *group); 20 14
-2
fs/notify/inotify/inotify.h
··· 25 25 struct fsnotify_group *group); 26 26 extern int inotify_handle_event(struct fsnotify_group *group, 27 27 struct inode *inode, 28 - struct fsnotify_mark *inode_mark, 29 - struct fsnotify_mark *vfsmount_mark, 30 28 u32 mask, const void *data, int data_type, 31 29 const unsigned char *file_name, u32 cookie, 32 30 struct fsnotify_iter_info *iter_info);
+3 -3
fs/notify/inotify/inotify_fsnotify.c
··· 65 65 66 66 int inotify_handle_event(struct fsnotify_group *group, 67 67 struct inode *inode, 68 - struct fsnotify_mark *inode_mark, 69 - struct fsnotify_mark *vfsmount_mark, 70 68 u32 mask, const void *data, int data_type, 71 69 const unsigned char *file_name, u32 cookie, 72 70 struct fsnotify_iter_info *iter_info) 73 71 { 72 + struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 74 73 struct inotify_inode_mark *i_mark; 75 74 struct inotify_event_info *event; 76 75 struct fsnotify_event *fsn_event; ··· 77 78 int len = 0; 78 79 int alloc_len = sizeof(struct inotify_event_info); 79 80 80 - BUG_ON(vfsmount_mark); 81 + if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info))) 82 + return 0; 81 83 82 84 if ((inode_mark->mask & FS_EXCL_UNLINK) && 83 85 (data_type == FSNOTIFY_EVENT_PATH)) {
+6 -2
fs/notify/inotify/inotify_user.c
··· 485 485 struct fsnotify_group *group) 486 486 { 487 487 struct inotify_inode_mark *i_mark; 488 + struct fsnotify_iter_info iter_info = { 489 + .inode_mark = fsn_mark, 490 + .report_mask = FSNOTIFY_OBJ_TYPE_INODE_FL, 491 + }; 488 492 489 493 /* Queue ignore event for the watch */ 490 - inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED, 491 - NULL, FSNOTIFY_EVENT_NONE, NULL, 0, NULL); 494 + inotify_handle_event(group, NULL, FS_IN_IGNORED, NULL, 495 + FSNOTIFY_EVENT_NONE, NULL, 0, &iter_info); 492 496 493 497 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); 494 498 /* remove this mark from the idr */
+18 -2
include/linux/fsnotify_backend.h
··· 98 98 struct fsnotify_ops { 99 99 int (*handle_event)(struct fsnotify_group *group, 100 100 struct inode *inode, 101 - struct fsnotify_mark *inode_mark, 102 - struct fsnotify_mark *vfsmount_mark, 103 101 u32 mask, const void *data, int data_type, 104 102 const unsigned char *file_name, u32 cookie, 105 103 struct fsnotify_iter_info *iter_info); ··· 209 211 #define FSNOTIFY_OBJ_TYPE_INODE_FL (1U << FSNOTIFY_OBJ_TYPE_INODE) 210 212 #define FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL (1U << FSNOTIFY_OBJ_TYPE_VFSMOUNT) 211 213 #define FSNOTIFY_OBJ_ALL_TYPES_MASK ((1U << FSNOTIFY_OBJ_TYPE_COUNT) - 1) 214 + 215 + struct fsnotify_iter_info { 216 + struct fsnotify_mark *inode_mark; 217 + struct fsnotify_mark *vfsmount_mark; 218 + unsigned int report_mask; 219 + int srcu_idx; 220 + }; 221 + 222 + #define FSNOTIFY_ITER_FUNCS(name, NAME) \ 223 + static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \ 224 + struct fsnotify_iter_info *iter_info) \ 225 + { \ 226 + return (iter_info->report_mask & FSNOTIFY_OBJ_TYPE_##NAME##_FL) ? \ 227 + iter_info->name##_mark : NULL; \ 228 + } 229 + 230 + FSNOTIFY_ITER_FUNCS(inode, INODE) 231 + FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT) 212 232 213 233 /* 214 234 * Inode / vfsmount point to this structure which tracks all marks attached to
+1 -2
kernel/audit_fsnotify.c
··· 165 165 /* Update mark data in audit rules based on fsnotify events. */ 166 166 static int audit_mark_handle_event(struct fsnotify_group *group, 167 167 struct inode *to_tell, 168 - struct fsnotify_mark *inode_mark, 169 - struct fsnotify_mark *vfsmount_mark, 170 168 u32 mask, const void *data, int data_type, 171 169 const unsigned char *dname, u32 cookie, 172 170 struct fsnotify_iter_info *iter_info) 173 171 { 172 + struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 174 173 struct audit_fsnotify_mark *audit_mark; 175 174 const struct inode *inode = NULL; 176 175
-2
kernel/audit_tree.c
··· 989 989 990 990 static int audit_tree_handle_event(struct fsnotify_group *group, 991 991 struct inode *to_tell, 992 - struct fsnotify_mark *inode_mark, 993 - struct fsnotify_mark *vfsmount_mark, 994 992 u32 mask, const void *data, int data_type, 995 993 const unsigned char *file_name, u32 cookie, 996 994 struct fsnotify_iter_info *iter_info)
+1 -2
kernel/audit_watch.c
··· 472 472 /* Update watch data in audit rules based on fsnotify events. */ 473 473 static int audit_watch_handle_event(struct fsnotify_group *group, 474 474 struct inode *to_tell, 475 - struct fsnotify_mark *inode_mark, 476 - struct fsnotify_mark *vfsmount_mark, 477 475 u32 mask, const void *data, int data_type, 478 476 const unsigned char *dname, u32 cookie, 479 477 struct fsnotify_iter_info *iter_info) 480 478 { 479 + struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); 481 480 const struct inode *inode; 482 481 struct audit_parent *parent; 483 482