Message ID | 20200414124304.4470-3-eesposit@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Simplefs: group and simplify linux fs code | expand |
On Tue, Apr 14, 2020 at 02:42:56PM +0200, Emanuele Giuseppe Esposito wrote: > We will augment this family of functions with inode management. To avoid > littering include/linux/fs.h and fs/libfs.c, move them to a separate header, > with a Kconfig symbol to enable them. > > Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> You have a lot of people on cc:, this is going to be hard for everyone to review... > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index d1398cef3b18..fc38a6f0fc11 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -288,12 +288,16 @@ config STRIP_ASM_SYMS > > config READABLE_ASM > bool "Generate readable assembler code" > - depends on DEBUG_KERNEL > - help > - Disable some compiler optimizations that tend to generate human unreadable > - assembler output. This may make the kernel slightly slower, but it helps > - to keep kernel developers who have to stare a lot at assembler listings > - sane. > + depends on DEBUG_KERNEL > + help > + Disable some compiler optimizations that tend to generate human unreadable > + assembler output. This may make the kernel slightly slower, but it helps > + to keep kernel developers who have to stare a lot at assembler listings > + sane. > + Why did you loose the indentation here and add trailing whitespace? > +config DEBUG_FS > + bool "Debug Filesystem" > + select SIMPLEFS > We already have a DEBUG_FS config option in this file, why another one? And what happened to the help text? I think you need to rework your patch series to do smaller things on each step, which would make it reviewable much easier, and prevent mistakes like this one. thanks, greg k-h
Hi Emanuele, Thank you for the patch! Yet something to improve: [auto build test ERROR on char-misc/char-misc-testing] [also build test ERROR on driver-core/driver-core-testing linus/master v5.7-rc1 next-20200414] [cannot apply to security/next-testing] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Emanuele-Giuseppe-Esposito/Simplefs-group-and-simplify-linux-fs-code/20200415-030834 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 885a64715fd81e6af6d94a038556e0b2e6deb19c config: arm-mvebu_v7_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=9.3.0 make.cross ARCH=arm If you fix the issue, kindly add following tag as appropriate Reported-by: kbuild test robot <lkp@intel.com> All errors (new ones prefixed by >>): arm-linux-gnueabi-ld: fs/tracefs/inode.o: in function `remove_one': >> inode.c:(.text+0x1c): undefined reference to `simple_release_fs' arm-linux-gnueabi-ld: fs/tracefs/inode.o: in function `start_creating.part.0': inode.c:(.text+0x454): undefined reference to `simple_release_fs' arm-linux-gnueabi-ld: fs/tracefs/inode.o: in function `__create_dir': >> inode.c:(.text+0x55c): undefined reference to `simple_pin_fs' >> arm-linux-gnueabi-ld: inode.c:(.text+0x640): undefined reference to `simple_release_fs' arm-linux-gnueabi-ld: fs/tracefs/inode.o: in function `tracefs_create_file': inode.c:(.text+0x690): undefined reference to `simple_pin_fs' arm-linux-gnueabi-ld: inode.c:(.text+0x75c): undefined reference to `simple_release_fs' arm-linux-gnueabi-ld: fs/tracefs/inode.o: in function `tracefs_remove': inode.c:(.text+0x79c): undefined reference to `simple_pin_fs' arm-linux-gnueabi-ld: inode.c:(.text+0x7c0): undefined reference to `simple_release_fs' --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Tue, Apr 14, 2020 at 02:42:56PM +0200, Emanuele Giuseppe Esposito wrote: > We will augment this family of functions with inode management. To avoid > littering include/linux/fs.h and fs/libfs.c, move them to a separate header, > with a Kconfig symbol to enable them. If there are no functional changes, indicating that on the commit log will make the review much easier. > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index d1398cef3b18..fc38a6f0fc11 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -288,12 +288,16 @@ config STRIP_ASM_SYMS > > config READABLE_ASM > bool "Generate readable assembler code" > - depends on DEBUG_KERNEL > - help > - Disable some compiler optimizations that tend to generate human unreadable > - assembler output. This may make the kernel slightly slower, but it helps > - to keep kernel developers who have to stare a lot at assembler listings > - sane. > + depends on DEBUG_KERNEL > + help > + Disable some compiler optimizations that tend to generate human unreadable > + assembler output. This may make the kernel slightly slower, but it helps > + to keep kernel developers who have to stare a lot at assembler listings > + sane. > + This minor change above should just be a separate patch. Its just noise otherwise. > +config DEBUG_FS > + bool "Debug Filesystem" > + select SIMPLEFS I'm at a loss reviewing this, my lib/Kconfig.debug already has a config DEBUG_FS. But above I see it is being added for the very first time. I'm sure there is some odd conditional which is obscuring this, can this be explained in the commit log? Luis
> diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig > index 39eec9031487..a62795079d9c 100644 > --- a/drivers/misc/cxl/Kconfig > +++ b/drivers/misc/cxl/Kconfig > @@ -19,6 +19,7 @@ config CXL > select CXL_BASE > select CXL_AFU_DRIVER_OPS > select CXL_LIB > + select SIMPLEFS > default m > help > Select this option to enable driver support for IBM Coherent > diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c > index b493de962153..0b8f8de7475a 100644 > --- a/drivers/misc/cxl/api.c > +++ b/drivers/misc/cxl/api.c > @@ -9,6 +9,7 @@ > #include <misc/cxl.h> > #include <linux/module.h> > #include <linux/mount.h> > +#include <linux/simplefs.h> > #include <linux/pseudo_fs.h> > #include <linux/sched/mm.h> > #include <linux/mmu_context.h> > diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig > index 2d2266c1439e..ddd9245fff3d 100644 > --- a/drivers/misc/ocxl/Kconfig > +++ b/drivers/misc/ocxl/Kconfig > @@ -12,6 +12,7 @@ config OCXL > depends on PPC_POWERNV && PCI && EEH > select OCXL_BASE > select HOTPLUG_PCI_POWERNV > + select SIMPLEFS It's not clear to me the Kconfig updated is needed for the ocxl driver. I think it's only needed for the cxl driver. Fred
On 4/21/20 1:19 PM, Frederic Barrat wrote: > > >> diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig >> index 39eec9031487..a62795079d9c 100644 >> --- a/drivers/misc/cxl/Kconfig >> +++ b/drivers/misc/cxl/Kconfig >> @@ -19,6 +19,7 @@ config CXL >> select CXL_BASE >> select CXL_AFU_DRIVER_OPS >> select CXL_LIB >> + select SIMPLEFS >> default m >> help >> Select this option to enable driver support for IBM Coherent >> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c >> index b493de962153..0b8f8de7475a 100644 >> --- a/drivers/misc/cxl/api.c >> +++ b/drivers/misc/cxl/api.c >> @@ -9,6 +9,7 @@ >> #include <misc/cxl.h> >> #include <linux/module.h> >> #include <linux/mount.h> >> +#include <linux/simplefs.h> >> #include <linux/pseudo_fs.h> >> #include <linux/sched/mm.h> >> #include <linux/mmu_context.h> >> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig >> index 2d2266c1439e..ddd9245fff3d 100644 >> --- a/drivers/misc/ocxl/Kconfig >> +++ b/drivers/misc/ocxl/Kconfig >> @@ -12,6 +12,7 @@ config OCXL >> depends on PPC_POWERNV && PCI && EEH >> select OCXL_BASE >> select HOTPLUG_PCI_POWERNV >> + select SIMPLEFS > > > It's not clear to me the Kconfig updated is needed for the ocxl driver. > I think it's only needed for the cxl driver. I am going to get rid of the separate simplefs.c file and related Kconfig entry and put everything in fs/libfs.c, so this file (together with many others touched in this patch) won't be modified in v2. Thanks, Emanuele
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 43594978958e..a6fe933de9da 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -14,6 +14,7 @@ menuconfig DRM select I2C select I2C_ALGOBIT select DMA_SHARED_BUFFER + select SIMPLEFS select SYNC_FILE help Kernel-level support for the Direct Rendering Infrastructure (DRI) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 7b1a628d1f6e..187a61091b5c 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -27,7 +27,7 @@ */ #include <linux/debugfs.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/mount.h> diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig index 39eec9031487..a62795079d9c 100644 --- a/drivers/misc/cxl/Kconfig +++ b/drivers/misc/cxl/Kconfig @@ -19,6 +19,7 @@ config CXL select CXL_BASE select CXL_AFU_DRIVER_OPS select CXL_LIB + select SIMPLEFS default m help Select this option to enable driver support for IBM Coherent diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index b493de962153..0b8f8de7475a 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -9,6 +9,7 @@ #include <misc/cxl.h> #include <linux/module.h> #include <linux/mount.h> +#include <linux/simplefs.h> #include <linux/pseudo_fs.h> #include <linux/sched/mm.h> #include <linux/mmu_context.h> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig index 2d2266c1439e..ddd9245fff3d 100644 --- a/drivers/misc/ocxl/Kconfig +++ b/drivers/misc/ocxl/Kconfig @@ -12,6 +12,7 @@ config OCXL depends on PPC_POWERNV && PCI && EEH select OCXL_BASE select HOTPLUG_PCI_POWERNV + select SIMPLEFS default m help Select this option to enable the ocxl driver for Open diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c index 7018cd802569..429f55651090 100644 --- a/drivers/scsi/cxlflash/ocxl_hw.c +++ b/drivers/scsi/cxlflash/ocxl_hw.c @@ -12,6 +12,7 @@ #include <linux/idr.h> #include <linux/module.h> #include <linux/mount.h> +#include <linux/simplefs.h> #include <linux/pseudo_fs.h> #include <linux/poll.h> #include <linux/sched/signal.h> diff --git a/fs/Kconfig b/fs/Kconfig index f08fbbfafd9a..a6795ae312a2 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -218,6 +218,9 @@ config HUGETLB_PAGE config MEMFD_CREATE def_bool TMPFS || HUGETLBFS +config SIMPLEFS + bool + config ARCH_HAS_GIGANTIC_PAGE bool diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 62dc4f577ba1..af7b765de4d3 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -176,6 +176,7 @@ config BINFMT_EM86 config BINFMT_MISC tristate "Kernel support for MISC binaries" + select SIMPLEFS ---help--- If you say Y here, it will be possible to plug wrapper-driven binary formats into the kernel. You will like this especially when you use diff --git a/fs/Makefile b/fs/Makefile index 2ce5112b02c8..c5c665984b9e 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_PROC_FS) += proc_namespace.o obj-y += notify/ obj-$(CONFIG_EPOLL) += eventpoll.o obj-y += anon_inodes.o +obj-$(CONFIG_SIMPLEFS) += simplefs.o obj-$(CONFIG_SIGNALFD) += signalfd.o obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index cdb45829354d..c764110f5f0b 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -25,7 +25,7 @@ #include <linux/mount.h> #include <linux/fs_context.h> #include <linux/syscalls.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/uaccess.h> #include "internal.h" diff --git a/fs/configfs/Kconfig b/fs/configfs/Kconfig index 272b64456999..3b461e4e3989 100644 --- a/fs/configfs/Kconfig +++ b/fs/configfs/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config CONFIGFS_FS tristate "Userspace-driven configuration filesystem" + select SIMPLEFS select SYSFS help configfs is a RAM-based filesystem that provides the converse diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 0c6e8cf61953..331c2f064f02 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -10,7 +10,7 @@ * configfs Copyright (C) 2005 Oracle. All rights reserved. */ -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/module.h> #include <linux/mount.h> #include <linux/fs_context.h> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b7f2e971ecbc..7b9fddced48f 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -13,7 +13,7 @@ #define pr_fmt(fmt) "debugfs: " fmt #include <linux/module.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/mount.h> #include <linux/pagemap.h> #include <linux/init.h> diff --git a/fs/libfs.c b/fs/libfs.c index 3759fbacf522..26ec729f7bcd 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -11,6 +11,7 @@ #include <linux/cred.h> #include <linux/mount.h> #include <linux/vfs.h> +#include <linux/simplefs.h> #include <linux/quotaops.h> #include <linux/mutex.h> #include <linux/namei.h> @@ -663,41 +664,6 @@ int simple_fill_super(struct super_block *s, unsigned long magic, } EXPORT_SYMBOL(simple_fill_super); -static DEFINE_SPINLOCK(pin_fs_lock); - -int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *count) -{ - struct vfsmount *mnt = NULL; - spin_lock(&pin_fs_lock); - if (unlikely(!*mount)) { - spin_unlock(&pin_fs_lock); - mnt = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL); - if (IS_ERR(mnt)) - return PTR_ERR(mnt); - spin_lock(&pin_fs_lock); - if (!*mount) - *mount = mnt; - } - mntget(*mount); - ++*count; - spin_unlock(&pin_fs_lock); - mntput(mnt); - return 0; -} -EXPORT_SYMBOL(simple_pin_fs); - -void simple_release_fs(struct vfsmount **mount, int *count) -{ - struct vfsmount *mnt; - spin_lock(&pin_fs_lock); - mnt = *mount; - if (!--*count) - *mount = NULL; - spin_unlock(&pin_fs_lock); - mntput(mnt); -} -EXPORT_SYMBOL(simple_release_fs); - /** * simple_read_from_buffer - copy data from the buffer to user space * @to: the user space buffer to read to diff --git a/fs/simplefs.c b/fs/simplefs.c new file mode 100644 index 000000000000..226d18963801 --- /dev/null +++ b/fs/simplefs.c @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <linux/simplefs.h> +#include <linux/mount.h> + +static DEFINE_SPINLOCK(pin_fs_lock); + +int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *count) +{ + struct vfsmount *mnt = NULL; + spin_lock(&pin_fs_lock); + if (unlikely(!*mount)) { + spin_unlock(&pin_fs_lock); + mnt = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL); + if (IS_ERR(mnt)) + return PTR_ERR(mnt); + spin_lock(&pin_fs_lock); + if (!*mount) + *mount = mnt; + } + mntget(*mount); + ++*count; + spin_unlock(&pin_fs_lock); + mntput(mnt); + return 0; +} +EXPORT_SYMBOL(simple_pin_fs); + +void simple_release_fs(struct vfsmount **mount, int *count) +{ + struct vfsmount *mnt; + spin_lock(&pin_fs_lock); + mnt = *mount; + if (!--*count) + *mount = NULL; + spin_unlock(&pin_fs_lock); + mntput(mnt); +} +EXPORT_SYMBOL(simple_release_fs); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 0ee8c6dfb036..4353ca81e1d7 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -10,7 +10,7 @@ */ #include <linux/module.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/mount.h> #include <linux/kobject.h> #include <linux/namei.h> diff --git a/include/linux/fs.h b/include/linux/fs.h index 4f6f59b4f22a..55b679b89c8a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3363,8 +3363,6 @@ struct tree_descr { const char *name; const struct file_operations *ops; int mod struct dentry *d_alloc_name(struct dentry *, const char *); extern int simple_fill_super(struct super_block *, unsigned long, const struct tree_descr *); -extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); -extern void simple_release_fs(struct vfsmount **mount, int *count); extern ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, const void *from, size_t available); diff --git a/include/linux/simplefs.h b/include/linux/simplefs.h new file mode 100644 index 000000000000..1076a44db308 --- /dev/null +++ b/include/linux/simplefs.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SIMPLEFS_H +#define _LINUX_SIMPLEFS_H + +#include <linux/fs.h> + +extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); +extern void simple_release_fs(struct vfsmount **mount, int *count); + +#endif diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d1398cef3b18..fc38a6f0fc11 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -288,12 +288,16 @@ config STRIP_ASM_SYMS config READABLE_ASM bool "Generate readable assembler code" - depends on DEBUG_KERNEL - help - Disable some compiler optimizations that tend to generate human unreadable - assembler output. This may make the kernel slightly slower, but it helps - to keep kernel developers who have to stare a lot at assembler listings - sane. + depends on DEBUG_KERNEL + help + Disable some compiler optimizations that tend to generate human unreadable + assembler output. This may make the kernel slightly slower, but it helps + to keep kernel developers who have to stare a lot at assembler listings + sane. + +config DEBUG_FS + bool "Debug Filesystem" + select SIMPLEFS config HEADERS_INSTALL bool "Install uapi headers to usr/include" diff --git a/security/Kconfig b/security/Kconfig index cd3cc7da3a55..2c6713aa8b4f 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -39,6 +39,7 @@ config SECURITY_WRITABLE_HOOKS config SECURITYFS bool "Enable the securityfs filesystem" + select SIMPLEFS help This will build the securityfs filesystem. It is currently used by various security modules (AppArmor, IMA, SafeSetID, TOMOYO, TPM). diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 828bb1eb77ea..d62d3fca47f2 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -18,7 +18,7 @@ #include <linux/namei.h> #include <linux/capability.h> #include <linux/rcupdate.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/fs_context.h> #include <linux/poll.h> #include <linux/zlib.h> @@ -2529,6 +2529,7 @@ static int aa_mk_null_file(struct dentry *parent) struct vfsmount *mount; struct dentry *dentry; struct inode *inode; + int error; mount = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL); if (IS_ERR(mount)) diff --git a/security/inode.c b/security/inode.c index 6c326939750d..a9a9ee4de21d 100644 --- a/security/inode.c +++ b/security/inode.c @@ -12,7 +12,7 @@ /* #define DEBUG */ #include <linux/sysfs.h> #include <linux/kobject.h> -#include <linux/fs.h> +#include <linux/simplefs.h> #include <linux/fs_context.h> #include <linux/mount.h> #include <linux/pagemap.h>
We will augment this family of functions with inode management. To avoid littering include/linux/fs.h and fs/libfs.c, move them to a separate header, with a Kconfig symbol to enable them. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> --- drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/drm_drv.c | 2 +- drivers/misc/cxl/Kconfig | 1 + drivers/misc/cxl/api.c | 1 + drivers/misc/ocxl/Kconfig | 1 + drivers/scsi/cxlflash/ocxl_hw.c | 1 + fs/Kconfig | 3 +++ fs/Kconfig.binfmt | 1 + fs/Makefile | 1 + fs/binfmt_misc.c | 2 +- fs/configfs/Kconfig | 1 + fs/configfs/mount.c | 2 +- fs/debugfs/inode.c | 2 +- fs/libfs.c | 36 +------------------------------ fs/simplefs.c | 38 +++++++++++++++++++++++++++++++++ fs/tracefs/inode.c | 2 +- include/linux/fs.h | 2 -- include/linux/simplefs.h | 10 +++++++++ lib/Kconfig.debug | 16 ++++++++------ security/Kconfig | 1 + security/apparmor/apparmorfs.c | 3 ++- security/inode.c | 2 +- 22 files changed, 79 insertions(+), 50 deletions(-) create mode 100644 fs/simplefs.c create mode 100644 include/linux/simplefs.h