fs: move getname and putname handlers into namei.h
Subsystems (17)
PATCH 1/2 fs: move getname and putname handlers into namei.h
This will enable use of runtime const machinery for namei_cachep. Existing header spaghetti makes it impossible to use while in fs.h
---
This may end up creating merge conflicts against the work which messed with audit and atomic refcounts on struct filename, but they should be trivially resolvable. Things just got moved fs.h -> namei.h
tested with allmodconfig
drivers/base/firmware_loader/main.c | 1 + fs/ceph/mds_client.h | 1 + fs/d_path.c | 1 + fs/exfat/dir.c | 1 + fs/f2fs/f2fs.h | 1 + fs/fat/dir.c | 1 + fs/filesystems.c | 1 + fs/ntfs3/dir.c | 1 + fs/ntfs3/fsntfs.c | 1 + fs/ntfs3/namei.c | 1 + fs/ntfs3/xattr.c | 1 + fs/smb/client/cifsproto.h | 1 + fs/vboxsf/file.c | 1 + include/linux/fs.h | 42 +---------------------------- include/linux/namei.h | 41 ++++++++++++++++++++++++++++ io_uring/statx.c | 1 + mm/huge_memory.c | 1 + security/integrity/ima/ima_api.c | 1 + security/integrity/ima/ima_main.c | 1 + 19 files changed, 59 insertions(+), 41 deletions(-)
drivers/base/firmware_loader/main.c +1 -0
@@ -29,6 +29,7 @@#include <linux/file.h> #include <linux/list.h> #include <linux/fs.h> +#include <linux/namei.h> #include <linux/async.h> #include <linux/pm.h> #include <linux/suspend.h>
fs/ceph/mds_client.h +1 -0
@@ -11,6 +11,7 @@#include <linux/refcount.h> #include <linux/utsname.h> #include <linux/ktime.h> +#include <linux/namei.h> #include <linux/ceph/types.h> #include <linux/ceph/messenger.h>
fs/d_path.c +1 -0
@@ -4,6 +4,7 @@#include <linux/uaccess.h> #include <linux/fs_struct.h> #include <linux/fs.h> +#include <linux/namei.h> #include <linux/slab.h> #include <linux/prefetch.h> #include "mount.h"
fs/exfat/dir.c +1 -0
@@ -7,6 +7,7 @@#include <linux/compat.h> #include <linux/bio.h> #include <linux/buffer_head.h> +#include <linux/namei.h> #include "exfat_raw.h" #include "exfat_fs.h"
fs/f2fs/f2fs.h +1 -0
@@ -24,6 +24,7 @@#include <linux/quotaops.h> #include <linux/part_stat.h> #include <linux/rw_hint.h> +#include <linux/namei.h> #include <linux/fscrypt.h> #include <linux/fsverity.h>
fs/fat/dir.c +1 -0
@@ -18,6 +18,7 @@#include <linux/compat.h> #include <linux/uaccess.h> #include <linux/iversion.h> +#include <linux/namei.h> #include "fat.h" /*
fs/filesystems.c +1 -0
@@ -17,6 +17,7 @@#include <linux/slab.h> #include <linux/uaccess.h> #include <linux/fs_parser.h> +#include <linux/namei.h> /* * Handling of filesystem drivers list.
fs/ntfs3/dir.c +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/fs.h> +#include <linux/namei.h> #include <linux/nls.h> #include "debug.h"
fs/ntfs3/fsntfs.c +1 -0
@@ -8,6 +8,7 @@#include <linux/blkdev.h> #include <linux/buffer_head.h> #include <linux/fs.h> +#include <linux/namei.h> #include <linux/kernel.h> #include <linux/nls.h>
fs/ntfs3/namei.c +1 -0
@@ -6,6 +6,7 @@*/ #include <linux/fs.h> +#include <linux/namei.h> #include <linux/nls.h> #include <linux/ctype.h> #include <linux/posix_acl.h>
fs/ntfs3/xattr.c +1 -0
@@ -6,6 +6,7 @@*/ #include <linux/fs.h> +#include <linux/namei.h> #include <linux/posix_acl.h> #include <linux/posix_acl_xattr.h> #include <linux/xattr.h>
fs/smb/client/cifsproto.h +1 -0
@@ -9,6 +9,7 @@#define _CIFSPROTO_H#include <linux/nls.h> #include <linux/ctype.h> +#include <linux/namei.h> #include "cifsglob.h" #include "trace.h" #ifdef CONFIG_CIFS_DFS_UPCALL
fs/vboxsf/file.c +1 -0
@@ -10,6 +10,7 @@#include <linux/pagemap.h> #include <linux/highmem.h> #include <linux/sizes.h> +#include <linux/namei.h> #include "vfsmod.h" struct vboxsf_handle {
include/linux/fs.h +1 -41
66 lines not on this page · raw message
include/linux/namei.h +41 -0
47 lines not on this page · raw message
io_uring/statx.c +1 -0
@@ -2,6 +2,7 @@#include <linux/kernel.h> #include <linux/errno.h> #include <linux/file.h> +#include <linux/namei.h> #include <linux/io_uring.h> #include <uapi/linux/io_uring.h>
mm/huge_memory.c +1 -0
@@ -40,6 +40,7 @@#include <linux/pgalloc.h> #include <linux/pgalloc_tag.h> #include <linux/pagewalk.h> +#include <linux/namei.h> #include <asm/tlb.h> #include "internal.h"
security/integrity/ima/ima_api.c +1 -0
@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/file.h> #include <linux/fs.h> +#include <linux/namei.h> #include <linux/xattr.h> #include <linux/evm.h> #include <linux/fsverity.h>
security/integrity/ima/ima_main.c +1 -0
@@ -25,6 +25,7 @@#include <linux/xattr.h> #include <linux/ima.h> #include <linux/fs.h> +#include <linux/namei.h> #include <linux/iversion.h> #include <linux/evm.h> #include <linux/crash_dump.h>
Signature · 1 line
2.48.1
PATCH 2/2 fs: hide namei_cachep behind runtime const machinery
--- fs/dcache.c | 7 ++++--- include/asm-generic/vmlinux.lds.h | 4 +++- include/linux/namei.h | 11 ++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-)
fs/dcache.c +4 -3
@@ -3282,8 +3282,8 @@ static void __init dcache_init(void) }/* SLAB cache for __getname() consumers */ -struct kmem_cache *names_cachep__ro_after_init ; -EXPORT_SYMBOL (names_cachep); +struct kmem_cache *__names_cachep__ro_after_init ; +EXPORT_SYMBOL (__names_cachep);void __init vfs_caches_init_early (void ) {
@@ -3298,8 +3298,9 @@ void __init vfs_caches_init_early(void)void __init vfs_caches_init (void ) { - names_cachep =kmem_cache_create_usercopy ("names_cache" ,PATH_MAX ,0 , + __names_cachep =kmem_cache_create_usercopy ("names_cache" ,PATH_MAX ,0 ,SLAB_HWCACHE_ALIGN |SLAB_PANIC ,0 ,PATH_MAX ,NULL ); +runtime_const_init (ptr, __names_cachep);dcache_init ();inode_init ();
include/asm-generic/vmlinux.lds.h +3 -1
@@ -972,7 +972,9 @@#define RUNTIME_CONST_VARIABLES \ RUNTIME_CONST(shift, d_hash_shift) \ RUNTIME_CONST(ptr, dentry_hashtable) \ - RUNTIME_CONST(ptr, __dentry_cache) + RUNTIME_CONST(ptr, __dentry_cache) \ + RUNTIME_CONST(ptr, __names_cachep) +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */ #define KUNIT_TABLE () \
include/linux/namei.h +10 -1
@@ -9,6 +9,10 @@#include <linux/errno.h> #include <linux/fs_struct.h> +#ifndef MODULE +#include <asm/runtime-const.h> +#endif +enum {MAX_NESTED_LINKS =8 };#define MAXSYMLINKS 40
@@ -88,7 +92,12 @@ static inline struct filename *refname(struct filename *name)return name; } -extern struct kmem_cache *names_cachep; +extern struct kmem_cache *__names_cachep; +#ifdef MODULE +#define names_cachep __names_cachep +#else +#define names_cachep runtime_const_ptr(__names_cachep) +#endif #define __getname () kmem_cache_alloc(names_cachep, GFP_KERNEL)#define __putname (name) kmem_cache_free(names_cachep, (void *)(name))
Signature · 1 line
2.48.1
self-NAK, i'm going to rebase on top of
https://lore.kernel.org/linux-fsdevel/[email protected]/
when the time comes
Al Viro
maintainerQuoted 3 lines · Mateusz Guzik
self-NAK, i'm going to rebase on top of
https://lore.kernel.org/linux-fsdevel/[email protected]/
when the time comes
FWIW, I'm putting together struct filename-related
branches for the next cycle (trying to figure out what's the best way to linearize the mess I've got).
If you throw a patch on top of the series I've posted
on Friday (and it should shrink a whole lot - the damn thing is static in fs/namei.c now, with cache initialization done in the same place) I would be glad to apply it.
Other series around struct filename for the next
cycle:
* DEFINE_CLASS(filename, struct filename *, putname(_T), getname(p), const char __user *p) EXTEND_CLASS(filename, _kernel, getname_kernel(p), const char *p) EXTEND_CLASS(filename, _flags, getname_flags(p, f), const char *p, unsigned int f) EXTEND_CLASS(filename, _uflags, getname_uflags(p, f), const char *p, unsigned int f) EXTEND_CLASS(filename, _maybe_null, getname_maybe_null(p, f), const char *p, unsigned int f) EXTEND_CLASS(filename, _consume, no_free_ptr(p), struct filename *p)
and an bunch of conversions making use of that. Generally I dislike RAII patterns, but uses of struct filename make a reasonably good fit.
* change of calling conventions for do_filp_open() - let it DTRT when it's given ERR_PTR() for name. Surprising amount of error handling in the callers (and callers of callers, etc.) folds into that. One thing that is very tempting is s/do_filp_open/do_file_open/, while we are at it...
* killing pointless checks for IS_ERR() before calling filename_lookup() and vfs_path_parent_lookup() - those already treat ERR_PTR() for name as "bail out immediately".
* [currently very tentative] dealing with __audit_inode(). It's a surprisingly convoluted series, and it's not quite finished yet. Not sure if that one won't end up slipping past 6.20...
Linearizing that stuff into something that would not be a hell wrt merges is... interesting.