From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
Josef Bacik <josef@toxicpanda.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>,
linux-kernel@vger.kernel.org, Hugh Dickins <hughd@google.com>,
linux-mm@kvack.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tejun Heo <tj@kernel.org>, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Jann Horn <jannh@google.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH 01/14] xattr: add rcu_head and rhash_head to struct simple_xattr
Date: Fri, 27 Feb 2026 15:43:28 +0100 [thread overview]
Message-ID: <vk7mausaumazk6iho7f2z7ld7byeyjhyczietf4rdi3c4dt3ya@ytbqtfdwvmfp> (raw)
In-Reply-To: <20260216-work-xattr-socket-v1-1-c2efa4f74cb7@kernel.org>
On Mon 16-02-26 14:31:57, Christian Brauner wrote:
> In preparation for converting simple_xattrs from rbtree to rhashtable,
> add rhash_head and rcu_head members to struct simple_xattr. The
> rhashtable implementation will use rhash_head for hash table linkage
> and RCU-based lockless reads, requiring that replaced or removed xattr
> entries be freed via call_rcu() rather than immediately.
>
> Add simple_xattr_free_rcu() which schedules RCU-deferred freeing of an
> xattr entry. This will be used by callers of simple_xattr_set() once
> they switch to the rhashtable-based xattr store.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/xattr.c | 23 +++++++++++++++++++++++
> include/linux/xattr.h | 4 ++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 3e49e612e1ba..9cbb1917bcb2 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -1197,6 +1197,29 @@ void simple_xattr_free(struct simple_xattr *xattr)
> kvfree(xattr);
> }
>
> +static void simple_xattr_rcu_free(struct rcu_head *head)
> +{
> + struct simple_xattr *xattr;
> +
> + xattr = container_of(head, struct simple_xattr, rcu);
> + simple_xattr_free(xattr);
> +}
> +
> +/**
> + * simple_xattr_free_rcu - free an xattr object after an RCU grace period
> + * @xattr: the xattr object
> + *
> + * Schedule RCU-deferred freeing of an xattr entry. This is used by
> + * rhashtable-based callers of simple_xattr_set() that replace or remove
> + * an existing entry while concurrent RCU readers may still be accessing
> + * it.
> + */
> +void simple_xattr_free_rcu(struct simple_xattr *xattr)
> +{
> + if (xattr)
> + call_rcu(&xattr->rcu, simple_xattr_rcu_free);
> +}
> +
> /**
> * simple_xattr_alloc - allocate new xattr object
> * @value: value of the xattr object
> diff --git a/include/linux/xattr.h b/include/linux/xattr.h
> index 64e9afe7d647..1328f2bfd2ce 100644
> --- a/include/linux/xattr.h
> +++ b/include/linux/xattr.h
> @@ -16,6 +16,7 @@
> #include <linux/types.h>
> #include <linux/spinlock.h>
> #include <linux/mm.h>
> +#include <linux/rhashtable-types.h>
> #include <linux/user_namespace.h>
> #include <uapi/linux/xattr.h>
>
> @@ -112,6 +113,8 @@ struct simple_xattrs {
>
> struct simple_xattr {
> struct rb_node rb_node;
> + struct rhash_head hash_node;
> + struct rcu_head rcu;
> char *name;
> size_t size;
> char value[];
> @@ -122,6 +125,7 @@ void simple_xattrs_free(struct simple_xattrs *xattrs, size_t *freed_space);
> size_t simple_xattr_space(const char *name, size_t size);
> struct simple_xattr *simple_xattr_alloc(const void *value, size_t size);
> void simple_xattr_free(struct simple_xattr *xattr);
> +void simple_xattr_free_rcu(struct simple_xattr *xattr);
> int simple_xattr_get(struct simple_xattrs *xattrs, const char *name,
> void *buffer, size_t size);
> struct simple_xattr *simple_xattr_set(struct simple_xattrs *xattrs,
>
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2026-02-27 14:43 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 13:31 [PATCH 00/14] xattr: rework simple xattrs and support user.* xattrs on sockets Christian Brauner
2026-02-16 13:31 ` [PATCH 01/14] xattr: add rcu_head and rhash_head to struct simple_xattr Christian Brauner
2026-02-27 14:43 ` Jan Kara [this message]
2026-02-16 13:31 ` [PATCH 02/14] xattr: add rhashtable-based simple_xattr infrastructure Christian Brauner
2026-02-27 14:43 ` Jan Kara
2026-02-16 13:31 ` [PATCH 03/14] shmem: adapt to rhashtable-based simple_xattrs with lazy allocation Christian Brauner
2026-02-27 14:48 ` Jan Kara
2026-02-16 13:32 ` [PATCH 04/14] kernfs: " Christian Brauner
2026-02-27 15:00 ` Jan Kara
2026-02-16 13:32 ` [PATCH 05/14] pidfs: adapt to rhashtable-based simple_xattrs Christian Brauner
2026-02-27 15:09 ` Jan Kara
2026-02-27 15:16 ` Jan Kara
2026-02-16 13:32 ` [PATCH 06/14] xattr: remove rbtree-based simple_xattr infrastructure Christian Brauner
2026-02-27 15:14 ` Jan Kara
2026-02-16 13:32 ` [PATCH 07/14] xattr: add xattr_permission_error() Christian Brauner
2026-02-27 15:15 ` Jan Kara
2026-02-16 13:32 ` [PATCH 08/14] xattr: switch xattr_permission() to switch statement Christian Brauner
2026-02-27 15:17 ` Jan Kara
2026-02-16 13:32 ` [PATCH 09/14] xattr: move user limits for xattrs to generic infra Christian Brauner
2026-02-21 0:03 ` Darrick J. Wong
2026-02-23 12:13 ` Christian Brauner
2026-02-27 15:20 ` Jan Kara
2026-02-16 13:32 ` [PATCH 10/14] xattr,net: support limited amount of extended attributes on sockfs sockets Christian Brauner
2026-02-27 15:25 ` Jan Kara
2026-02-16 13:32 ` [PATCH 11/14] xattr: support extended attributes on sockets Christian Brauner
2026-02-27 15:26 ` Jan Kara
2026-02-16 13:32 ` [PATCH 12/14] selftests/xattr: path-based AF_UNIX socket xattr tests Christian Brauner
2026-02-27 15:29 ` Jan Kara
2026-02-16 13:32 ` [PATCH 13/14] selftests/xattr: sockfs " Christian Brauner
2026-02-27 15:30 ` Jan Kara
2026-02-16 13:32 ` [PATCH 14/14] selftests/xattr: test xattrs on various socket families Christian Brauner
2026-02-27 15:32 ` Jan Kara
2026-02-20 0:44 ` [PATCH 00/14] xattr: rework simple xattrs and support user.* xattrs on sockets Darrick J. Wong
2026-02-20 9:23 ` Christian Brauner
2026-02-21 0:14 ` Darrick J. Wong
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=vk7mausaumazk6iho7f2z7ld7byeyjhyczietf4rdi3c4dt3ya@ytbqtfdwvmfp \
--to=jack@suse.cz \
--cc=brauner@kernel.org \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hughd@google.com \
--cc=jannh@google.com \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox