From nobody Thu Apr 2 22:05:40 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E18D35DD13 for ; Thu, 12 Feb 2026 21:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770933513; cv=none; b=KEUEhgAxm4J9BGx3pNkJmPxnTd3E0AAfCdwFnq2lt8h/ZkkK5BnHDofSMkm/VJTIuG6D7wgBmN5h7g9BCkkJU6eVHPc8OhLLCugw3siIR2ya7KpBud2wEKVps/vgyF65SmvqkZiZEnQkIs7ZCb9X3M8lxxVTOEkvHJmr4bXnBk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770933513; c=relaxed/simple; bh=cddz7yiNNtZcRMbECFzY2RrBpOd+pdNNI+Dx9a521G0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tcisBeAvH9luYOTU+sjmNXzL9HciVsULCUHYANZxT6dp5UfyRX0Xiad6GTcBxrBAr97cNqg1Oc9gd0OKR9BA0O5y2QUk9EKYZ8DBav5g55SjaWJjx8oJ/9sm8JVv8fHvVtaBmrRhKDiiEpYiIz9OLhC3uDPAStkzgF1ZBucq1Y0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=OgOaRaf3; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OgOaRaf3" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3562171b56dso249775a91.2 for ; Thu, 12 Feb 2026 13:58:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770933511; x=1771538311; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=F9QIJ7/JNUJlnhiwP3aDc1NcdR+8wgC780wGHRVk+o8=; b=OgOaRaf37vhBtHyCrP3d6E4o6GDVE174CiT1tFdoq35UW+RZumKLiGLZhVNorLvyLH VK009YlDwcnMrFrOVNfprc01roOhwIUuFiVRy1gq9etX/MnTIOVu9xfxgOzhXpc288gu MvwJDLqHydjFUmUuSBL6OvVf0c25o/7Bfqgv130ieL4UZPRAHTV1GbGmAbM8f8f26muW oGhHN6yNqqC5iNATmJG32MmJegxnETit56bLO/QTq0zIlFXKdNmtFaAQuSjeAlb2kzT7 wDBxPc1y6Hso9hIkc8PDGMx+ChE1/MJ1kXvSa34JIgWra1TXhMQr/yneGpuWUZNvoe7/ WgEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770933511; x=1771538311; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F9QIJ7/JNUJlnhiwP3aDc1NcdR+8wgC780wGHRVk+o8=; b=wnrNdEwYxdyLWe7jkJWfGKuVomzlSq1+at2hKYXe9/TzFWTp/NDk6sz1PW/6TpN2Si COAaDVnQlGueWQrI4obTvfba4lmCXWkqmwxMvjYtLXAJuKW96YWWHqXJib34woHdj8OY R9wGalTTd6WKmD88rC8sV/VAYtrr2XB37VtLTOCqRAcSaAjCRSGYQ3/slH4ZOJMZlPCB TMTbTHusd0OcxQ5Ve1U+TUh0eu408gPrPhsP03rTZv2sXGkKfpAqcnbqwvXxe/6x6pce jZgU8P135g2BS6WNP84ic2Io2gPbtcg1pubZD6xJbnxvShpxsOwNb1o2LU+peQBuV5PC 761Q== X-Forwarded-Encrypted: i=1; AJvYcCWfTER4H8Pozdx6kEBUKIS3kfA7U5WXgBrq5nP1/S9SyYClW9KkgMKgp1x3KYeMRc4hLda4nmxaSl3IiDM=@vger.kernel.org X-Gm-Message-State: AOJu0YxBVkNzykx6HWFNRMDtZ90fPt6KIOC6KZ9lTlNfjfD2eYUzrfnh o2FCpImPcUNw7UXJLzgvp1aQW1mkHCu8uAXL5Vpad5oo5q6ZlCulgSINjxzznajUoWkB8nBvNut Biwe9q/VmJyXqS7H0nw== X-Received: from pjob16.prod.google.com ([2002:a17:90a:8c90:b0:34b:e29d:f74c]) (user=tjmercier job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d90:b0:356:22ef:57b9 with SMTP id 98e67ed59e1d1-356a7641a8emr399373a91.3.1770933510727; Thu, 12 Feb 2026 13:58:30 -0800 (PST) Date: Thu, 12 Feb 2026 13:58:12 -0800 In-Reply-To: <20260212215814.629709-1-tjmercier@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260212215814.629709-1-tjmercier@google.com> X-Mailer: git-send-email 2.53.0.273.g2a3d683680-goog Message-ID: <20260212215814.629709-2-tjmercier@google.com> Subject: [PATCH v2 1/3] kernfs: allow passing fsnotify event types From: "T.J. Mercier" 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" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Amir Goldstein --- 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 *wo= rk) 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 *wo= rk) } kernfs_notify_list =3D kn->attr.notify_next; kn->attr.notify_next =3D NULL; + notify_event =3D kn->attr.notify_event; + kn->attr.notify_event =3D 0; spin_unlock_irq(&kernfs_notify_lock); =20 root =3D kernfs_root(kn); @@ -954,7 +957,7 @@ static void kernfs_notify_workfn(struct work_struct *wo= rk) if (parent) { p_inode =3D 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 *wo= rk) } =20 if (!p_inode) - fsnotify_inode(inode, FS_MODIFY); + fsnotify_inode(inode, notify_event); =20 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 =3D kernfs_notify_list; + kn->attr.notify_event =3D FS_MODIFY; kernfs_notify_list =3D 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() */ }; =20 /* --=20 2.53.0.273.g2a3d683680-goog