On Thu, Feb 12, 2026 at 01:58:12PM -0800, T.J. Mercier wrote:
> The kernfs_notify function is hardcoded to only issue FS_MODIFY events
> since that is the only current use case. Allow for supporting other
> events by adding a notify_event field to kernfs_elem_attr. The
> limitation of only one queued event per kernfs_node continues to exist
> as a consequence of the design of the kernfs_notify_list. The new
> notify_event field is protected by the same kernfs_notify_lock as the
> existing notify_next field.
> 
> Signed-off-by: T.J. Mercier <[email protected]>

Looks fine
Feel free to add
Acked-by: Amir Goldstein <[email protected]>

> ---
>  fs/kernfs/file.c       | 8 ++++++--
>  include/linux/kernfs.h | 1 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index 9adf36e6364b..e978284ff983 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -914,6 +914,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
>       struct kernfs_node *kn;
>       struct kernfs_super_info *info;
>       struct kernfs_root *root;
> +     u32 notify_event;
>  repeat:
>       /* pop one off the notify_list */
>       spin_lock_irq(&kernfs_notify_lock);
> @@ -924,6 +925,8 @@ static void kernfs_notify_workfn(struct work_struct *work)
>       }
>       kernfs_notify_list = kn->attr.notify_next;
>       kn->attr.notify_next = NULL;
> +     notify_event = kn->attr.notify_event;
> +     kn->attr.notify_event = 0;
>       spin_unlock_irq(&kernfs_notify_lock);
>  
>       root = kernfs_root(kn);
> @@ -954,7 +957,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
>               if (parent) {
>                       p_inode = ilookup(info->sb, kernfs_ino(parent));
>                       if (p_inode) {
> -                             fsnotify(FS_MODIFY | FS_EVENT_ON_CHILD,
> +                             fsnotify(notify_event | FS_EVENT_ON_CHILD,
>                                        inode, FSNOTIFY_EVENT_INODE,
>                                        p_inode, &name, inode, 0);
>                               iput(p_inode);
> @@ -964,7 +967,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
>               }
>  
>               if (!p_inode)
> -                     fsnotify_inode(inode, FS_MODIFY);
> +                     fsnotify_inode(inode, notify_event);
>  
>               iput(inode);
>       }
> @@ -1005,6 +1008,7 @@ void kernfs_notify(struct kernfs_node *kn)
>       if (!kn->attr.notify_next) {
>               kernfs_get(kn);
>               kn->attr.notify_next = kernfs_notify_list;
> +             kn->attr.notify_event = FS_MODIFY;
>               kernfs_notify_list = kn;
>               schedule_work(&kernfs_notify_work);
>       }
> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index b5a5f32fdfd1..1762b32c1a8e 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -181,6 +181,7 @@ struct kernfs_elem_attr {
>       struct kernfs_open_node __rcu   *open;
>       loff_t                  size;
>       struct kernfs_node      *notify_next;   /* for kernfs_notify() */
> +     u32                     notify_event;   /* for kernfs_notify() */
>  };
>  
>  /*
> -- 
> 2.53.0.273.g2a3d683680-goog
> 

Reply via email to