From: "T.J. Mercier" <tjmercier@google.com>
To: gregkh@linuxfoundation.org, tj@kernel.org,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org
Cc: "T.J. Mercier" <tjmercier@google.com>
Subject: [PATCH v2 1/3] kernfs: allow passing fsnotify event types
Date: Thu, 12 Feb 2026 13:58:12 -0800 [thread overview]
Message-ID: <20260212215814.629709-2-tjmercier@google.com> (raw)
In-Reply-To: <20260212215814.629709-1-tjmercier@google.com>
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 <tjmercier@google.com>
---
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
next prev parent reply other threads:[~2026-02-12 21:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 21:58 [PATCH v2 0/3] kernfs: Add inotify IN_DELETE_SELF, IN_IGNORED support for files T.J. Mercier
2026-02-12 21:58 ` T.J. Mercier [this message]
2026-02-16 16:27 ` [PATCH v2 1/3] kernfs: allow passing fsnotify event types Amir Goldstein
2026-02-17 19:27 ` T.J. Mercier
2026-02-12 21:58 ` [PATCH v2 2/3] kernfs: send IN_DELETE_SELF and IN_IGNORED on file deletion T.J. Mercier
2026-02-17 10:18 ` Amir Goldstein
2026-02-17 19:25 ` T.J. Mercier
2026-02-17 21:25 ` Amir Goldstein
2026-02-17 22:32 ` T.J. Mercier
2026-02-17 23:13 ` Amir Goldstein
2026-02-18 11:23 ` Jan Kara
2026-02-12 21:58 ` [PATCH v2 3/3] selftests: memcg: Add tests IN_DELETE_SELF and IN_IGNORED on memory.events T.J. Mercier
2026-02-16 16:21 ` [PATCH v2 0/3] kernfs: Add inotify IN_DELETE_SELF, IN_IGNORED support for files Amir Goldstein
2026-02-17 19:25 ` T.J. Mercier
2026-02-17 6:43 ` Tejun Heo
2026-02-17 19:25 ` T.J. Mercier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260212215814.629709-2-tjmercier@google.com \
--to=tjmercier@google.com \
--cc=cgroups@vger.kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.