History

fsnotify: remove dirent events from FS_EVENTS_POSS_ON_CHILD mask

"dirent" events are referring to events that modify directory entries, such as create,delete,rename. Those events are always be reported on a watched directory, regardless if FS_EVENT_ON_CHILD is set on the watch mask. ALL_FSNOTIFY_DIRENT_EVENTS defines all the dirent event types and those event types are removed from FS_EVENTS_POSS_ON_CHILD. That means for a directory with an inotify watch and only dirent events in the mask (i.e. create,delete,move), all children dentries will no longer have the DCACHE_FSNOTIFY_PARENT_WATCHED flag set. This will allow all events that happen on children to be optimized away in __fsnotify_parent() without the need to dereference child->d_parent->d_inode->i_fsnotify_mask. Since the dirent events are never repoted via __fsnotify_parent(), this results in no change of logic, but only an optimization.

Amir Goldstein committed 7 years ago

Commit e2201401 parent 5f02a871 file · +21 −15Browse files

Unified · Split

include/linux/fsnotify_backend.h+21−15
@@ -59,27 +59,33 @@ · 58 unmodified lines
5959 * dnotify and inotify. */
6060 #define FS_EVENT_ON_CHILD 0x08000000
6161
62−/* This is a list of all events that may get sent to a parernt based on fs event
63− * happening to inodes inside that directory */
64−#define FS_EVENTS_POSS_ON_CHILD (FS_ACCESS | FS_MODIFY | FS_ATTRIB |\
65− FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN |\
66− FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\
67− FS_DELETE | FS_OPEN_PERM | FS_ACCESS_PERM | \
68− FS_OPEN_EXEC | FS_OPEN_EXEC_PERM)
69−
7062 #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO)
7163
64+/*
65+ * Directory entry modification events - reported only to directory
66+ * where entry is modified and not to a watching parent.
67+ * The watching parent may get an FS_ATTRIB|FS_EVENT_ON_CHILD event
68+ * when a directory entry inside a child subdir changes.
69+ */
70+#define ALL_FSNOTIFY_DIRENT_EVENTS (FS_CREATE | FS_DELETE | FS_MOVE)
71+
7272 #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM | \
7373 FS_OPEN_EXEC_PERM)
7474
75+/*
76+ * This is a list of all events that may get sent to a parent based on fs event
77+ * happening to inodes inside that directory.
78+ */
79+#define FS_EVENTS_POSS_ON_CHILD (ALL_FSNOTIFY_PERM_EVENTS | \
80+ FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
81+ FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | \
82+ FS_OPEN | FS_OPEN_EXEC)
83+
7584 /* Events that can be reported to backends */
76−#define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
77− FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \
78− FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \
79− FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \
80− FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \
81− FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME | \
82− FS_OPEN_EXEC | FS_OPEN_EXEC_PERM)
85+#define ALL_FSNOTIFY_EVENTS (ALL_FSNOTIFY_DIRENT_EVENTS | \
86+ FS_EVENTS_POSS_ON_CHILD | \
87+ FS_DELETE_SELF | FS_MOVE_SELF | FS_DN_RENAME | \
88+ FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED)
8389
8490 /* Extra flags that may be reported with event or control handling of events */
8591 #define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t