path: drop IN_ATTRIB from parent directory watches
authorRonan Pigott <ronan@rjp.ie>
Mon, 1 Jul 2024 21:07:28 +0000 (14:07 -0700)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Jul 2024 09:58:15 +0000 (11:58 +0200)
commit8bf8c7d83dcffffa55b5f534fb98db6b01315dc1
tree607c52b798e1636cfb7b518e0a593317c0dbb46a
parent355fbedf1f7a19b00f2802ececd9771aafae6232
path: drop IN_ATTRIB from parent directory watches

When watching a given pathspec, systemd unconditionally installs
IN_ATTRIB watches to track the link count of the resolved file. This
way, we are notified if the watched path disappears, even if the
resolved file inode is not removed.

Similarly, systemd installs inotify watches on each parent directory, to
be notified when the specified path appears. However, for these watches
IN_ATTRIB is an unnecessary addition to the mask. In inotify, IN_ATTRIB
on a directory is emitted whenever the attributes of any child changes,
which, for many paths, has the potential to cause a high number of
spurious wakeups in systemd. Let's remove IN_ATTRIB from the mask when
installing watches on the parent directories of the specified path.
src/core/path.c