Skip to content

Commit 6ba8d71

Browse files
amir73iljankara
authored andcommitted
fsnotify: add object type "child" to object type iterator
The object type iterator is used to collect all the marks of a specific group that have interest in an event. It is used by fanotify to get a single handle_event callback when an event has a match to either of inode/sb/mount marks of the group. The nature of fsnotify events is that they are associated with at most one sb at most one mount and at most one inode. When a parent and child are both watching, two events are sent to backend, one associated to parent inode and one associated to the child inode. This results in duplicate events in fanotify, which usually get merged before user reads them, but this is sub-optimal. It would be better if the same event is sent to backend with an object type iterator that has both the child inode and its parent, and let the backend decide if the event should be reported once (fanotify) or twice (inotify). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 85af5d9 commit 6ba8d71

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/linux/fsnotify_backend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,15 @@ static inline const struct path *fsnotify_data_path(const void *data,
253253

254254
enum fsnotify_obj_type {
255255
FSNOTIFY_OBJ_TYPE_INODE,
256+
FSNOTIFY_OBJ_TYPE_CHILD,
256257
FSNOTIFY_OBJ_TYPE_VFSMOUNT,
257258
FSNOTIFY_OBJ_TYPE_SB,
258259
FSNOTIFY_OBJ_TYPE_COUNT,
259260
FSNOTIFY_OBJ_TYPE_DETACHED = FSNOTIFY_OBJ_TYPE_COUNT
260261
};
261262

262263
#define FSNOTIFY_OBJ_TYPE_INODE_FL (1U << FSNOTIFY_OBJ_TYPE_INODE)
264+
#define FSNOTIFY_OBJ_TYPE_CHILD_FL (1U << FSNOTIFY_OBJ_TYPE_CHILD)
263265
#define FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL (1U << FSNOTIFY_OBJ_TYPE_VFSMOUNT)
264266
#define FSNOTIFY_OBJ_TYPE_SB_FL (1U << FSNOTIFY_OBJ_TYPE_SB)
265267
#define FSNOTIFY_OBJ_ALL_TYPES_MASK ((1U << FSNOTIFY_OBJ_TYPE_COUNT) - 1)
@@ -304,6 +306,7 @@ static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \
304306
}
305307

306308
FSNOTIFY_ITER_FUNCS(inode, INODE)
309+
FSNOTIFY_ITER_FUNCS(child, CHILD)
307310
FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT)
308311
FSNOTIFY_ITER_FUNCS(sb, SB)
309312

0 commit comments

Comments
 (0)