@@ -337,10 +337,25 @@ static inline struct fs_error_report *fsnotify_data_error_report(
337337 }
338338}
339339
340+ /*
341+ * Index to merged marks iterator array that correlates to a type of watch.
342+ * The type of watched object can be deduced from the iterator type, but not
343+ * the other way around, because an event can match different watched objects
344+ * of the same object type.
345+ * For example, both parent and child are watching an object of type inode.
346+ */
347+ enum fsnotify_iter_type {
348+ FSNOTIFY_ITER_TYPE_INODE ,
349+ FSNOTIFY_ITER_TYPE_VFSMOUNT ,
350+ FSNOTIFY_ITER_TYPE_SB ,
351+ FSNOTIFY_ITER_TYPE_PARENT ,
352+ FSNOTIFY_ITER_TYPE_COUNT
353+ };
354+
355+ /* The type of object that a mark is attached to */
340356enum fsnotify_obj_type {
341357 FSNOTIFY_OBJ_TYPE_ANY = -1 ,
342358 FSNOTIFY_OBJ_TYPE_INODE ,
343- FSNOTIFY_OBJ_TYPE_PARENT ,
344359 FSNOTIFY_OBJ_TYPE_VFSMOUNT ,
345360 FSNOTIFY_OBJ_TYPE_SB ,
346361 FSNOTIFY_OBJ_TYPE_COUNT ,
@@ -353,46 +368,46 @@ static inline bool fsnotify_valid_obj_type(unsigned int obj_type)
353368}
354369
355370struct fsnotify_iter_info {
356- struct fsnotify_mark * marks [FSNOTIFY_OBJ_TYPE_COUNT ];
371+ struct fsnotify_mark * marks [FSNOTIFY_ITER_TYPE_COUNT ];
357372 unsigned int report_mask ;
358373 int srcu_idx ;
359374};
360375
361376static inline bool fsnotify_iter_should_report_type (
362- struct fsnotify_iter_info * iter_info , int type )
377+ struct fsnotify_iter_info * iter_info , int iter_type )
363378{
364- return (iter_info -> report_mask & (1U << type ));
379+ return (iter_info -> report_mask & (1U << iter_type ));
365380}
366381
367382static inline void fsnotify_iter_set_report_type (
368- struct fsnotify_iter_info * iter_info , int type )
383+ struct fsnotify_iter_info * iter_info , int iter_type )
369384{
370- iter_info -> report_mask |= (1U << type );
385+ iter_info -> report_mask |= (1U << iter_type );
371386}
372387
373388static inline void fsnotify_iter_set_report_type_mark (
374- struct fsnotify_iter_info * iter_info , int type ,
389+ struct fsnotify_iter_info * iter_info , int iter_type ,
375390 struct fsnotify_mark * mark )
376391{
377- iter_info -> marks [type ] = mark ;
378- iter_info -> report_mask |= (1U << type );
392+ iter_info -> marks [iter_type ] = mark ;
393+ iter_info -> report_mask |= (1U << iter_type );
379394}
380395
381396#define FSNOTIFY_ITER_FUNCS (name , NAME ) \
382397static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \
383398 struct fsnotify_iter_info *iter_info) \
384399{ \
385- return (iter_info->report_mask & (1U << FSNOTIFY_OBJ_TYPE_ ##NAME)) ? \
386- iter_info->marks[FSNOTIFY_OBJ_TYPE_ ##NAME] : NULL; \
400+ return (iter_info->report_mask & (1U << FSNOTIFY_ITER_TYPE_ ##NAME)) ? \
401+ iter_info->marks[FSNOTIFY_ITER_TYPE_ ##NAME] : NULL; \
387402}
388403
389404FSNOTIFY_ITER_FUNCS (inode , INODE )
390405FSNOTIFY_ITER_FUNCS (parent , PARENT )
391406FSNOTIFY_ITER_FUNCS (vfsmount , VFSMOUNT )
392407FSNOTIFY_ITER_FUNCS (sb , SB )
393408
394- #define fsnotify_foreach_obj_type (type ) \
395- for (type = 0; type < FSNOTIFY_OBJ_TYPE_COUNT ; type++)
409+ #define fsnotify_foreach_iter_type (type ) \
410+ for (type = 0; type < FSNOTIFY_ITER_TYPE_COUNT ; type++)
396411
397412/*
398413 * fsnotify_connp_t is what we embed in objects which connector can be attached
0 commit comments