All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Song Liu <songliubraving@fb.com>,
	linux-usb@vger.kernel.org, bpf@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	dri-devel@lists.freedesktop.org,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Hugh Dickins <hughd@google.com>,
	Paul Mackerras <paulus@samba.org>,
	John Johansen <john.johansen@canonical.com>,
	linux-s390@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	linux-efi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux-rdma@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
	Mark Fasheh <mark@fasheh.com>, Anton Vorontsov <anton@enomsg.org>,
	John Fastabend <john.fastabend@gmail.com>,
	James Morris <jmorris@namei.org>,
	Ard Biesheuvel <ardb@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	Doug Ledford <dledford@redhat.com>,
	oprofile-list@lists.sf.net, Yonghong Song <yhs@fb.com>,
	Ian Kent <raven@themaw.net>, Andrii Nakryiko <andriin@fb.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	netdev@vger.kernel.org, Robert Richter <rric@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Tony Luck <tony.luck@intel.com>,
	Kees Cook <keescook@chromium.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	autofs@vger.kernel.org, Uma Krishnan <ukrishn@linux.ibm.com>,
	linux-fsdevel@vger.kernel.org,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jakub Kicinski <kuba@kernel.org>, KP Singh <kpsingh@chromium.org>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Felipe Balbi <balbi@kernel.org>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Iurii Zaikin <yzaikin@google.com>,
	linux-scsi@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-mm@kvack.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>, Jeremy Kerr <jk@ozlabs.org>,
	Colin Cross <ccross@android.com>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau <kafai@fb.com>,
	ocfs2-devel@oss.oracle.com, Joel Becker <jlbec@evilplan.org>
Subject: [Ocfs2-devel] [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
Date: Tue, 14 Apr 2020 14:42:56 +0200	[thread overview]
Message-ID: <20200414124304.4470-3-eesposit@redhat.com> (raw)
In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com>

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

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>
-- 
2.25.2

WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Jeremy Kerr <jk@ozlabs.org>, Arnd Bergmann <arnd@arndb.de>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Robert Richter <rric@kernel.org>,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Felipe Balbi <balbi@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Ian Kent <raven@themaw.net>, Joel Becker <jlbec@evilplan.org>,
	Christoph Hellwig <hch@lst.de>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Mark Fasheh <mark@fasheh.com>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Iurii Zaikin <yzaikin@google.com>,
	Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>, Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	John Johansen <john.johansen@canonical.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-s390@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-rdma@vger.kernel.org, oprofile-list@lists.sf.net,
	linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, autofs@vger.kernel.org,
	linux-efi@vger.kernel.org, linux-mm@kvack.org,
	ocfs2-devel@oss.oracle.com, netdev@vger.kernel.org,
	bpf@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
Date: Tue, 14 Apr 2020 14:42:56 +0200	[thread overview]
Message-ID: <20200414124304.4470-3-eesposit@redhat.com> (raw)
In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com>

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

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>
-- 
2.25.2



WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Song Liu <songliubraving@fb.com>,
	linux-usb@vger.kernel.org, bpf@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	dri-devel@lists.freedesktop.org,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Hugh Dickins <hughd@google.com>,
	Paul Mackerras <paulus@samba.org>,
	John Johansen <john.johansen@canonical.com>,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	linux-efi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux-rdma@vger.kernel.org, Mark Fasheh <mark@fasheh.com>,
	Anton Vorontsov <anton@enomsg.org>,
	John Fastabend <john.fastabend@gmail.com>,
	James Morris <jmorris@namei.org>,
	Ard Biesheuvel <ardb@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	Doug Ledford <dledford@redhat.com>,
	oprofile-list@lists.sf.net, Yonghong Song <yhs@fb.com>,
	Ian Kent <raven@themaw.net>, Andrii Nakryiko <andriin@fb.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Robert Richter <rric@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Tony Luck <tony.luck@intel.com>,
	Kees Cook <keescook@chromium.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	autofs@vger.kernel.org,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	Maxime Ripard <mripard@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jakub Kicinski <kuba@kernel.org>, KP Singh <kpsingh@chromium.org>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Felipe Balbi <balbi@kernel.org>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Iurii Zaikin <yzaikin@google.com>,
	linux-scsi@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-mm@kvack.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>, Jeremy Kerr <jk@ozlabs.org>,
	Daniel Vetter <daniel@ffwll.ch>, Colin Cross <ccross@android.com>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau <kafai@fb.com>,
	ocfs2-devel@oss.oracle.com, Joel Becker <jlbec@evilplan.org>
Subject: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
Date: Tue, 14 Apr 2020 14:42:56 +0200	[thread overview]
Message-ID: <20200414124304.4470-3-eesposit@redhat.com> (raw)
In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com>

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

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>
-- 
2.25.2


WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Song Liu <songliubraving@fb.com>,
	linux-usb@vger.kernel.org, bpf@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	dri-devel@lists.freedesktop.org,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Hugh Dickins <hughd@google.com>,
	Paul Mackerras <paulus@samba.org>,
	John Johansen <john.johansen@canonical.com>,
	linux-s390@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	linux-efi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux-rdma@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
	Mark Fasheh <mark@fasheh.com>, Anton Vorontsov <anton@enomsg.org>,
	John Fastabend <john.fastabend@gmail.com>,
	James Morris <jmorris@namei.org>,
	Ard Biesheuvel <ardb@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	Doug Ledford <dledford@redhat.com>,
	oprofile-list@lists.sf.net, Yonghong Song <yhs@fb.com>,
	Ian Kent <raven@themaw.net>, Andrii Nakryiko <andriin@fb.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	netdev@vger.kernel.org, Robert Richter <rric@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Tony Luck <tony.luck@intel.com>,
	Kees Cook <keescook@chromium.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	autofs@vger.kernel.org, Uma Krishnan <ukrishn@linux.ibm.com>,
	linux-fsdevel@vger.kernel.org,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jakub Kicinski <kuba@kernel.org>, KP Singh <kpsingh@chromium.org>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Felipe Balbi <balbi@kernel.org>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Iurii Zaikin <yzaikin@google.com>,
	linux-scsi@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-mm@kvack.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>, Jeremy Kerr <jk@ozlabs.org>,
	Colin Cross <ccross@android.com>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau <kafai@fb.com>,
	ocfs2-devel@oss.oracle.com, Joel Becker <jlbec@evilplan.org>
Subject: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
Date: Tue, 14 Apr 2020 14:42:56 +0200	[thread overview]
Message-ID: <20200414124304.4470-3-eesposit@redhat.com> (raw)
In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com>

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

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>
-- 
2.25.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: Song Liu <songliubraving@fb.com>,
	linux-usb@vger.kernel.org, bpf@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	dri-devel@lists.freedesktop.org,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Hugh Dickins <hughd@google.com>,
	Paul Mackerras <paulus@samba.org>,
	John Johansen <john.johansen@canonical.com>,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Matthew Garrett <matthew.garrett@nebula.com>,
	linux-efi@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux-rdma@vger.kernel.org, Mark Fasheh <mark@fasheh.>
Subject: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
Date: Tue, 14 Apr 2020 14:42:56 +0200	[thread overview]
Message-ID: <20200414124304.4470-3-eesposit@redhat.com> (raw)
In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com>

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

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>
-- 
2.25.2


  parent reply	other threads:[~2020-04-14 12:42 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 12:42 [Ocfs2-devel] [PATCH 0/8] Simplefs: group and simplify linux fs code Emanuele Giuseppe Esposito
2020-04-14 12:42 ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` [Ocfs2-devel] [PATCH 1/8] apparmor: just use vfs_kern_mount to make .null Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-15 12:52   ` kbuild test robot
2020-04-15 12:52     ` kbuild test robot
2020-04-16  6:44   ` [Ocfs2-devel] " Luis Chamberlain
2020-04-16  6:44     ` Luis Chamberlain
2020-04-16  6:44     ` Luis Chamberlain
2020-04-16  6:44     ` Luis Chamberlain
2020-04-16  6:44     ` Luis Chamberlain
2020-04-20 14:00     ` Emanuele Giuseppe Esposito
2020-04-20 14:00       ` Emanuele Giuseppe Esposito
2020-04-20 14:00       ` Emanuele Giuseppe Esposito
2020-04-20 14:00       ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` Emanuele Giuseppe Esposito [this message]
2020-04-14 12:42   ` [PATCH 2/8] fs: extract simple_pin/release_fs to separate files Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:54   ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-14 12:54     ` Greg Kroah-Hartman
2020-04-14 12:54     ` Greg Kroah-Hartman
2020-04-14 12:54     ` Greg Kroah-Hartman
2020-04-14 12:54     ` Greg Kroah-Hartman
2020-04-15  0:57   ` kbuild test robot
2020-04-15  0:57     ` kbuild test robot
2020-04-15  0:57     ` kbuild test robot
2020-04-16  6:52   ` [Ocfs2-devel] " Luis Chamberlain
2020-04-16  6:52     ` Luis Chamberlain
2020-04-16  6:52     ` Luis Chamberlain
2020-04-16  6:52     ` Luis Chamberlain
2020-04-16  6:52     ` Luis Chamberlain
2020-04-21 11:19   ` [Ocfs2-devel] " Frederic Barrat
2020-04-21 11:19     ` Frederic Barrat
2020-04-21 11:19     ` Frederic Barrat
2020-04-21 11:19     ` Frederic Barrat
2020-04-21 11:19     ` Frederic Barrat
2020-04-21 11:26     ` [Ocfs2-devel] " Emanuele Giuseppe Esposito
2020-04-21 11:26       ` Emanuele Giuseppe Esposito
2020-04-21 11:26       ` Emanuele Giuseppe Esposito
2020-04-21 11:26       ` Emanuele Giuseppe Esposito
2020-04-21 11:26       ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` [Ocfs2-devel] [PATCH 3/8] fs: wrap simple_pin_fs/simple_release_fs arguments in a struct Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 13:03   ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-14 13:03     ` Greg Kroah-Hartman
2020-04-14 13:03     ` Greg Kroah-Hartman
2020-04-14 13:03     ` Greg Kroah-Hartman
2020-04-14 13:03     ` Greg Kroah-Hartman
2020-04-14 23:24   ` kbuild test robot
2020-04-14 23:24     ` kbuild test robot
2020-04-14 12:42 ` [Ocfs2-devel] [PATCH 4/8] fs: introduce simple_new_inode Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 13:01   ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-14 13:01     ` Greg Kroah-Hartman
2020-04-14 13:01     ` Greg Kroah-Hartman
2020-04-14 13:01     ` Greg Kroah-Hartman
2020-04-14 13:01     ` Greg Kroah-Hartman
2020-04-20 13:58     ` [Ocfs2-devel] " Emanuele Giuseppe Esposito
2020-04-20 13:58       ` Emanuele Giuseppe Esposito
2020-04-20 13:58       ` Emanuele Giuseppe Esposito
2020-04-20 13:58       ` Emanuele Giuseppe Esposito
2020-04-20 13:58       ` Emanuele Giuseppe Esposito
2020-04-14 12:42 ` [Ocfs2-devel] [PATCH 5/8] simplefs: add alloc_anon_inode wrapper Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:42   ` Emanuele Giuseppe Esposito
2020-04-14 12:55   ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-14 12:55     ` Greg Kroah-Hartman
2020-04-14 12:55     ` Greg Kroah-Hartman
2020-04-14 12:55     ` Greg Kroah-Hartman
2020-04-14 12:55     ` Greg Kroah-Hartman
2020-04-14 12:43 ` [Ocfs2-devel] [PATCH 6/8] simplefs: add file creation functions Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:56   ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-14 12:56     ` Greg Kroah-Hartman
2020-04-14 12:56     ` Greg Kroah-Hartman
2020-04-14 12:56     ` Greg Kroah-Hartman
2020-04-14 12:56     ` Greg Kroah-Hartman
2020-04-20 13:57     ` [Ocfs2-devel] " Emanuele Giuseppe Esposito
2020-04-20 13:57       ` Emanuele Giuseppe Esposito
2020-04-20 13:57       ` Emanuele Giuseppe Esposito
2020-04-20 13:57       ` Emanuele Giuseppe Esposito
2020-04-20 13:57       ` Emanuele Giuseppe Esposito
2020-04-20 14:28       ` [Ocfs2-devel] " Greg Kroah-Hartman
2020-04-20 14:28         ` Greg Kroah-Hartman
2020-04-20 14:28         ` Greg Kroah-Hartman
2020-04-20 14:28         ` Greg Kroah-Hartman
2020-04-20 14:28         ` Greg Kroah-Hartman
2020-04-20 14:33         ` [Ocfs2-devel] " Paolo Bonzini
2020-04-20 14:33           ` Paolo Bonzini
2020-04-20 14:33           ` Paolo Bonzini
2020-04-20 14:33           ` Paolo Bonzini
2020-04-20 14:33           ` Paolo Bonzini
2020-04-14 12:43 ` [Ocfs2-devel] [PATCH 7/8] debugfs: switch to simplefs inode creation API Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43 ` [Ocfs2-devel] [PATCH 8/8] tracefs: " Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-14 12:43   ` Emanuele Giuseppe Esposito
2020-04-16  6:59 ` [Ocfs2-devel] [PATCH 0/8] Simplefs: group and simplify linux fs code Luis Chamberlain
2020-04-16  6:59   ` Luis Chamberlain
2020-04-16  6:59   ` Luis Chamberlain
2020-04-16  6:59   ` Luis Chamberlain
2020-04-16  6:59   ` Luis Chamberlain
2020-04-20 14:01   ` Emanuele Giuseppe Esposito
2020-04-20 14:01     ` Emanuele Giuseppe Esposito
2020-04-20 14:01     ` Emanuele Giuseppe Esposito
2020-04-20 14:01     ` Emanuele Giuseppe Esposito

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=20200414124304.4470-3-eesposit@redhat.com \
    --to=eesposit@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=airlied@linux.ie \
    --cc=ajd@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriin@fb.com \
    --cc=anna.schumaker@netapp.com \
    --cc=anton@enomsg.org \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=autofs@vger.kernel.org \
    --cc=balbi@kernel.org \
    --cc=bfields@fieldses.org \
    --cc=borntraeger@de.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=ccross@android.com \
    --cc=chuck.lever@oracle.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dennis.dalessandro@intel.com \
    --cc=dledford@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fbarrat@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hughd@google.com \
    --cc=jejb@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=jk@ozlabs.org \
    --cc=jlbec@evilplan.org \
    --cc=jmorris@namei.org \
    --cc=john.fastabend@gmail.com \
    --cc=john.johansen@canonical.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=kafai@fb.com \
    --cc=keescook@chromium.org \
    --cc=kpsingh@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=manoj@linux.ibm.com \
    --cc=mark@fasheh.com \
    --cc=martin.petersen@oracle.com \
    --cc=matthew.garrett@nebula.com \
    --cc=mcgrof@kernel.org \
    --cc=mike.kravetz@oracle.com \
    --cc=mike.marciniszyn@intel.com \
    --cc=miklos@szeredi.hu \
    --cc=mpe@ellerman.id.au \
    --cc=mrochs@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=oprofile-list@lists.sf.net \
    --cc=paulus@samba.org \
    --cc=pbonzini@redhat.com \
    --cc=rafael@kernel.org \
    --cc=raven@themaw.net \
    --cc=rric@kernel.org \
    --cc=serge@hallyn.com \
    --cc=songliubraving@fb.com \
    --cc=tony.luck@intel.com \
    --cc=trond.myklebust@hammerspace.com \
    --cc=tzimmermann@suse.de \
    --cc=ukrishn@linux.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yhs@fb.com \
    --cc=yzaikin@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.