anon_inodes.c cleanups

1) anon_inode_inode can be read_mostly, same as anon_inode_mnt.
2) The IS_ERR(anon_inode_inode) check is unneeded, since we panic on
   boot if that were true.
3) anon_inode_mkinode has one caller, so it's a little confusing.
4) Don't clean up before panic.
5) Panic gives less information than an oops would, plus is untested.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 fs/anon_inodes.c |   66 +++++++++++++++----------------------------------------
 1 file changed, 18 insertions(+), 48 deletions(-)

diff -r 159b6a999a2d fs/anon_inodes.c
--- a/fs/anon_inodes.c	Tue Aug 12 17:50:01 2008 +1000
+++ b/fs/anon_inodes.c	Tue Aug 12 17:50:09 2008 +1000
@@ -22,7 +22,7 @@
 #include <asm/uaccess.h>
 
 static struct vfsmount *anon_inode_mnt __read_mostly;
-static struct inode *anon_inode_inode;
+static struct inode *anon_inode_inode __read_mostly;
 static const struct file_operations anon_inode_fops;
 
 static int anon_inodefs_get_sb(struct file_system_type *fs_type, int flags,
@@ -75,9 +75,6 @@ int anon_inode_getfd(const char *name, c
 	struct dentry *dentry;
 	struct file *file;
 	int error, fd;
-
-	if (IS_ERR(anon_inode_inode))
-		return -ENODEV;
 
 	error = get_unused_fd_flags(flags);
 	if (error < 0)
@@ -132,19 +129,18 @@ err_put_unused_fd:
 }
 EXPORT_SYMBOL_GPL(anon_inode_getfd);
 
-/*
- * A single inode exists for all anon_inode files. Contrary to pipes,
- * anon_inode inodes have no associated per-instance data, so we need
- * only allocate one of them.
- */
-static struct inode *anon_inode_mkinode(void)
+static int __init anon_inode_init(void)
 {
-	struct inode *inode = new_inode(anon_inode_mnt->mnt_sb);
+	register_filesystem(&anon_inode_fs_type);
+	anon_inode_mnt = kern_mount(&anon_inode_fs_type);
+	anon_inode_inode = new_inode(anon_inode_mnt->mnt_sb);
 
-	if (!inode)
-		return ERR_PTR(-ENOMEM);
-
-	inode->i_fop = &anon_inode_fops;
+	/*
+	 * A single inode exists for all anon_inode files. Contrary to pipes,
+	 * anon_inode inodes have no associated per-instance data, so we need
+	 * only allocate one of them.
+	 */
+	anon_inode_inode->i_fop = &anon_inode_fops;
 
 	/*
 	 * Mark the inode dirty from the very beginning,
@@ -152,41 +148,15 @@ static struct inode *anon_inode_mkinode(
 	 * list because mark_inode_dirty() will think
 	 * that it already _is_ on the dirty list.
 	 */
-	inode->i_state = I_DIRTY;
-	inode->i_mode = S_IRUSR | S_IWUSR;
-	inode->i_uid = current->fsuid;
-	inode->i_gid = current->fsgid;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-	return inode;
-}
-
-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;
-	}
-	anon_inode_inode = anon_inode_mkinode();
-	if (IS_ERR(anon_inode_inode)) {
-		error = PTR_ERR(anon_inode_inode);
-		goto err_mntput;
-	}
+	anon_inode_inode->i_state = I_DIRTY;
+	anon_inode_inode->i_mode = S_IRUSR | S_IWUSR;
+	anon_inode_inode->i_uid = current->fsuid;
+	anon_inode_inode->i_gid = current->fsgid;
+	anon_inode_inode->i_atime =
+		anon_inode_inode->i_mtime =
+		anon_inode_inode->i_ctime = CURRENT_TIME;
 
 	return 0;
-
-err_mntput:
-	mntput(anon_inode_mnt);
-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);
-
