Skip to content

Report more information in fanotify dirent events

Amir Goldstein linux-api linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7fsnotify: pass dentry instead of inode data for move eventsinclude/linux/fsnotify.h+3 -40 replies
2/7fanotify: introduce group flag FAN_REPORT_TARGET_FIDfs/notify/fanotify/fanotify.c fs/notify/fanotify/fanotify_user.c include/uapi/linux/fanotify.h+49 -120 replies
3/7fanotify: use macros to get the offset to fanotify_info bufferfs/notify/fanotify/fanotify.c fs/notify/fanotify/fanotify.h+31 -120 replies
4/7fanotify: support secondary dir fh and name in fanotify_infofs/notify/fanotify/fanotify.c fs/notify/fanotify/fanotify.h fs/notify/fanotify/fanotify_user.c+70 -100 replies
5/7fanotify: record new parent and name in MOVED_FROM eventfs/notify/fanotify/fanotify.c+37 -33 replies
6/7fanotify: report new parent and name in MOVED_FROM eventfs/notify/fanotify/fanotify.h fs/notify/fanotify/fanotify_user.c include/uapi/linux/fanotify.h+45 -20 replies
7/7fanotify: enable the FAN_REPORT_TARGET_FID flagfs/notify/fanotify/fanotify_user.c include/linux/fanotify.h+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/7] Report more information in fanotify dirent events

Jan,

This patch set follows up on the discussion on FAN_REPORT_TARGET_FID [1] from 3 months ago.

With FAN_REPORT_PIDFD in 5.15 and FAN_FS_ERROR on its way to 5.16, I figured we could get an early (re)start of the discussion on FAN_REPORT_TARGET_FID towards 5.17.

The added information in dirent events solves problems for my use case - It helps getting the following information in a race free manner:
1. fid of a created directory on mkdir
2. from/to path information on rename of non-dir

I realize those are two different API traits, but they are close enough so I preferred not to clutter the REPORT flags space any further than it already is. The single added flag FAN_REPORT_TARGET_FID adds:
1. child fid info to CREATE/DELETE/MOVED_* events
2. new parent+name info to MOVED_FROM event

Instead of going the "inotify way" and trying to join the MOVED_FROM/ MOVED_TO events using a cookie, I chose to incorporate the new parent+name intomation only in the MOVED_FROM event.
I made this choice for several reasons:
1. Availability of the moved dentry in the hook and event data
2. First info record is the old parent+name, like FAN_REPORT_DFID_NAME
3. Unlike, MOVED_TO, MOVED_FROM was useless for applications that use DFID_NAME info to statat(2) the object as we suggested

I chose to reduce testing complexity and require all other FID flags with FAN_REPORT_TARGET_FID and there is a convenience macro FAN_REPORT_ALL_FIDS that application can use.
This restriction could be relaxed in the future if we have a good reason to do so.

Since the POC branch 3 months ago, I dropped the 'sub_type' field of the info header, because it did not add much value IMO.

Patches [2] and LTP test [3] are available on my github.

Thanks,
Amir.

[1] https://lore.kernel.org/linux-fsdevel/CAOQ4uxjYDDk00VPdWtRB1_tf+gCoPFgSQ9O0p0fGaW_JiFUUKA@mail.gmail.com/
[2] https://github.com/amir73il/linux/commits/fanotify_target_fid
[3] https://github.com/amir73il/ltp/commits/fanotify_target_fid

Amir Goldstein (7):
fsnotify: pass dentry instead of inode data for move events
fanotify: introduce group flag FAN_REPORT_TARGET_FID
fanotify: use macros to get the offset to fanotify_info buffer
fanotify: support secondary dir fh and name in fanotify_info
fanotify: record new parent and name in MOVED_FROM event
fanotify: report new parent and name in MOVED_FROM event
fanotify: enable the FAN_REPORT_TARGET_FID flag

 fs/notify/fanotify/fanotify.c      | 108 ++++++++++++++++++++++-----
 fs/notify/fanotify/fanotify.h      | 113 +++++++++++++++++++++++++----
 fs/notify/fanotify/fanotify_user.c |  43 +++++++++--
 include/linux/fanotify.h           |   2 +-
 include/linux/fsnotify.h           |   7 +-
 include/uapi/linux/fanotify.h      |   5 ++
 6 files changed, 235 insertions(+), 43 deletions(-)
Signature · 1 line
2.33.1