We currently always chase a pointer inode->i_sb->s_user_ns whenever we need to map a uid/gid. Linus reported in [1] that this is noticable during path lookup. In the majority of cases we don't need to bother with that pointer chase because the inode won't be located on a filesystem that's mounted in a user namespace. The user namespace of the superblock cannot ever change once it's mounted. So introduce and raise IOP_USERNS on all inodes and check for that flag in relevant helpers. [1]: https://lore.kernel.org/CAHk-=whJgRDtxTudTQ9HV8BFw5-bBsu+c8Ouwd_PrPqPB6_KEQ@xxxxxxxxxxxxxx Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> --- Changes in v2: - Don't fully inline low-level helpers. - Link to v1: https://lore.kernel.org/20250416-work-mnt_idmap-s_user_ns-v1-0-273bef3a61ec@xxxxxxxxxx --- Christian Brauner (2): mnt_idmapping: don't bother with initial_idmapping() in {from,make}_vfs{g,u}id() inode: add fastpath for filesystem user namespace retrieval fs/inode.c | 8 ++++++++ fs/mnt_idmapping.c | 46 ++----------------------------------------- include/linux/fs.h | 23 +++++++++++++++++++--- include/linux/mnt_idmapping.h | 5 +++++ 4 files changed, 35 insertions(+), 47 deletions(-) --- base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8 change-id: 20250416-work-mnt_idmap-s_user_ns-eb57ee83e1d6