* [PATCH] kernfs: avoid iattr allocation in listxattr
@ 2026-07-31 12:05 Yichong Chen
2026-08-02 19:42 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Yichong Chen @ 2026-07-31 12:05 UTC (permalink / raw)
To: gregkh; +Cc: tj, driver-core, linux-kernel, Yichong Chen
kernfs_iop_listxattr() only needs to report existing xattrs, but it uses
kernfs_iattrs(), which allocates kernfs_iattrs when the node does not
have one yet.
This makes a query operation create persistent per-node metadata even
when the xattr list is empty.
Use kernfs_iattrs_noalloc() instead and return an empty list when no
iattrs exist.
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
fs/kernfs/inode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 2cb20294aaf5..237dcdd73fc2 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -141,9 +141,9 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
struct kernfs_node *kn = kernfs_dentry_node(dentry);
struct kernfs_iattrs *attrs;
- attrs = kernfs_iattrs(kn);
+ attrs = kernfs_iattrs_noalloc(kn);
if (!attrs)
- return -ENOMEM;
+ return 0;
return simple_xattr_list(d_inode(dentry), &attrs->xattrs, buf, size);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kernfs: avoid iattr allocation in listxattr
2026-07-31 12:05 [PATCH] kernfs: avoid iattr allocation in listxattr Yichong Chen
@ 2026-08-02 19:42 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-08-02 19:42 UTC (permalink / raw)
To: Yichong Chen; +Cc: gregkh, driver-core, linux-kernel
On Fri, Jul 31, 2026 at 08:05:54PM +0800, Yichong Chen wrote:
> kernfs_iop_listxattr() only needs to report existing xattrs, but it uses
> kernfs_iattrs(), which allocates kernfs_iattrs when the node does not
> have one yet.
>
> This makes a query operation create persistent per-node metadata even
> when the xattr list is empty.
>
> Use kernfs_iattrs_noalloc() instead and return an empty list when no
> iattrs exist.
>
> Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-02 19:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 12:05 [PATCH] kernfs: avoid iattr allocation in listxattr Yichong Chen
2026-08-02 19:42 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox