linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC] do we want pipefs et.al. in /proc/filesystems?
Date: Thu, 10 Oct 2013 01:47:32 +0100	[thread overview]
Message-ID: <20131010004732.GJ13318@ZenIV.linux.org.uk> (raw)

	We used to require register_filesystem() before any mounts
(including the internal ones) could be done.  For userland mounts
it's obviously right - how else could fs type name -> file_system_type
lookup be done?  For internal ones, it used to be really needed for
a while, but after some API massage (about 10 years ago, IIRC) it really
became pointless - kern_mount() takes a pointer to file_system_type
and doesn't bother with searching for it by name.  For a while there
was one remaining reason - the list of struct superblock belonging to
given fs type was a list_head one, with register_filesystem() initializing
the list.  A couple of years ago we switched to hlist, which doesn't
require anything of that sort - hlist_head initialized to NULL is an
empty list.

	These days there's no reason to register the filesystem types
that can only be used for internal mounts - ia64 pfmfs, anon_inodes,
bdev, pipefs and sockfs, in the current tree.  The only user-visible
effect of dropping those register_filesystem() would be shorter
/proc/filesystems - that bunch wouldn't be mentioned there anymore.
Does anything care about that?  FWIW, the diff eliminating those
would be as below (net/socket.c init leaks on early failures;
I'd left that as-is - it's a separate story).

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 5a9ff1c..bb3968e 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -1529,16 +1529,10 @@ static struct vfsmount *pfmfs_mnt __read_mostly;
 static int __init
 init_pfm_fs(void)
 {
-	int err = register_filesystem(&pfm_fs_type);
-	if (!err) {
-		pfmfs_mnt = kern_mount(&pfm_fs_type);
-		err = PTR_ERR(pfmfs_mnt);
-		if (IS_ERR(pfmfs_mnt))
-			unregister_filesystem(&pfm_fs_type);
-		else
-			err = 0;
-	}
-	return err;
+	pfmfs_mnt = kern_mount(&pfm_fs_type);
+	if (IS_ERR(pfmfs_mnt))
+		return PTR_ERR(pfmfs_mnt);
+	return 0;
 }
 
 static ssize_t
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 2408473..ad56c5a 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -175,22 +175,11 @@ EXPORT_SYMBOL_GPL(anon_inode_getfd);
 
 static int __init anon_inode_init(void)
 {
-	int error;
-
-	error = register_filesystem(&anon_inode_fs_type);
-	if (error)
-		goto err_exit;
 	anon_inode_mnt = kern_mount(&anon_inode_fs_type);
-	if (IS_ERR(anon_inode_mnt)) {
-		error = PTR_ERR(anon_inode_mnt);
-		goto err_unregister_filesystem;
-	}
+	if (IS_ERR(anon_inode_mnt))
+		panic("anon_inode_init() failed (%ld)\n",
+			PTR_ERR(anon_inode_mnt));
 	return 0;
-
-err_unregister_filesystem:
-	unregister_filesystem(&anon_inode_fs_type);
-err_exit:
-	panic(KERN_ERR "anon_inode_init() failed (%d)\n", error);
 }
 
 fs_initcall(anon_inode_init);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1e86823..ff3bf6a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -461,9 +461,6 @@ void __init bdev_cache_init(void)
 			0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
 				SLAB_MEM_SPREAD|SLAB_PANIC),
 			init_once);
-	err = register_filesystem(&bd_type);
-	if (err)
-		panic("Cannot register bdev pseudo-fs");
 	bd_mnt = kern_mount(&bd_type);
 	if (IS_ERR(bd_mnt))
 		panic("Cannot create bdev pseudo-fs");
diff --git a/fs/pipe.c b/fs/pipe.c
index d2c45e14..7a63d0a 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1311,16 +1311,10 @@ static struct file_system_type pipe_fs_type = {
 
 static int __init init_pipe_fs(void)
 {
-	int err = register_filesystem(&pipe_fs_type);
-
-	if (!err) {
-		pipe_mnt = kern_mount(&pipe_fs_type);
-		if (IS_ERR(pipe_mnt)) {
-			err = PTR_ERR(pipe_mnt);
-			unregister_filesystem(&pipe_fs_type);
-		}
-	}
-	return err;
+	pipe_mnt = kern_mount(&pipe_fs_type);
+	if (IS_ERR(pipe_mnt))
+		panic("pipe init failed\n");
+	return 0;
 }
 
 fs_initcall(init_pipe_fs);
diff --git a/net/socket.c b/net/socket.c
index ebed4b6..ea534a3 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2617,7 +2617,7 @@ static int __init sock_init(void)
 	 */
 	err = net_sysctl_init();
 	if (err)
-		goto out;
+		return err;
 
 	/*
 	 *      Initialize skbuff SLAB cache
@@ -2630,14 +2630,9 @@ static int __init sock_init(void)
 
 	init_inodecache();
 
-	err = register_filesystem(&sock_fs_type);
-	if (err)
-		goto out_fs;
 	sock_mnt = kern_mount(&sock_fs_type);
-	if (IS_ERR(sock_mnt)) {
-		err = PTR_ERR(sock_mnt);
-		goto out_mount;
-	}
+	if (IS_ERR(sock_mnt))
+		return PTR_ERR(sock_mnt);
 
 	/* The real protocol initialization is performed in later initcalls.
 	 */
@@ -2645,20 +2640,13 @@ static int __init sock_init(void)
 #ifdef CONFIG_NETFILTER
 	err = netfilter_init();
 	if (err)
-		goto out;
+		return err;
 #endif
 
 #ifdef CONFIG_NETWORK_PHY_TIMESTAMPING
 	skb_timestamping_init();
 #endif
-
-out:
-	return err;
-
-out_mount:
-	unregister_filesystem(&sock_fs_type);
-out_fs:
-	goto out;
+	return 0;
 }
 
 core_initcall(sock_init);	/* early initcall */

             reply	other threads:[~2013-10-10  0:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-10  0:47 Al Viro [this message]
2013-10-10  2:41 ` [RFC] do we want pipefs et.al. in /proc/filesystems? Linus Torvalds

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=20131010004732.GJ13318@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).