]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xattr: add rhashtable-based simple_xattr infrastructure
authorChristian Brauner <brauner@kernel.org>
Mon, 16 Feb 2026 13:31:58 +0000 (14:31 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 23 Feb 2026 12:06:38 +0000 (13:06 +0100)
commitb32c4a213698ab351b44da2fd1b2a5976c7fa033
treefa3baa49acd5e1c871269173b68826375dedb855
parent94d709be8c0dc875dfc9ebb64d3b8093d0790c15
xattr: add rhashtable-based simple_xattr infrastructure

Add rhashtable support to the simple_xattr subsystem while keeping the
existing rbtree code fully functional. This allows consumers to be
migrated one at a time without breaking any intermediate build.

struct simple_xattrs gains a dispatch flag and a union holding either
the rbtree (rb_root + rwlock) or rhashtable state:

  struct simple_xattrs {
      bool use_rhashtable;
      union {
          struct { struct rb_root rb_root; rwlock_t lock; };
          struct rhashtable ht;
      };
  };

simple_xattrs_init() continues to set up the rbtree path for existing
embedded-struct callers.

Add simple_xattrs_alloc() which dynamically allocates a simple_xattrs
and initializes the rhashtable path. This is the entry point for
consumers switching to pointer-based lazy allocation.

The five core functions (get, set, list, add, free) dispatch based on
the use_rhashtable flag.

Existing callers continue to use the rbtree path unchanged. As each
consumer is converted it will switch to simple_xattrs_alloc() and the
rhashtable path. Once all consumers are converted a follow-up patch
will remove the rbtree code.

Link: https://patch.msgid.link/20260216-work-xattr-socket-v1-2-c2efa4f74cb7@kernel.org
Acked-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xattr.c
include/linux/xattr.h
mm/shmem.c