Re: [PATCH] kernfs: avoid iattr allocation in listxattr

From: Tejun Heo

Date: Sun Aug 02 2026 - 15:42:34 EST


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@xxxxxxxxxxxxx>

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks.

--
tejun