efs: get rid of ->put_super()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Dec 2013 22:05:05 +0000 (17:05 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 Jan 2014 08:13:02 +0000 (03:13 -0500)
simplifies failure exits in ->mount()...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/efs/super.c

index c6f57a7..50215bb 100644 (file)
@@ -26,11 +26,18 @@ static struct dentry *efs_mount(struct file_system_type *fs_type,
        return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super);
 }
 
+static void efs_kill_sb(struct super_block *s)
+{
+       struct efs_sb_info *sbi = SUPER_INFO(s);
+       kill_block_super(s);
+       kfree(sbi);
+}
+
 static struct file_system_type efs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "efs",
        .mount          = efs_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = efs_kill_sb,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("efs");
@@ -105,12 +112,6 @@ static void destroy_inodecache(void)
        kmem_cache_destroy(efs_inode_cachep);
 }
 
-static void efs_put_super(struct super_block *s)
-{
-       kfree(s->s_fs_info);
-       s->s_fs_info = NULL;
-}
-
 static int efs_remount(struct super_block *sb, int *flags, char *data)
 {
        *flags |= MS_RDONLY;
@@ -120,7 +121,6 @@ static int efs_remount(struct super_block *sb, int *flags, char *data)
 static const struct super_operations efs_superblock_operations = {
        .alloc_inode    = efs_alloc_inode,
        .destroy_inode  = efs_destroy_inode,
-       .put_super      = efs_put_super,
        .statfs         = efs_statfs,
        .remount_fs     = efs_remount,
 };
@@ -259,7 +259,6 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        struct efs_sb_info *sb;
        struct buffer_head *bh;
        struct inode *root;
-       int ret = -EINVAL;
 
        sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
        if (!sb)
@@ -270,7 +269,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
                printk(KERN_ERR "EFS: device does not support %d byte blocks\n",
                        EFS_BLOCKSIZE);
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
   
        /* read the vh (volume header) block */
@@ -278,7 +277,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
 
        if (!bh) {
                printk(KERN_ERR "EFS: cannot read volume header\n");
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
 
        /*
@@ -290,13 +289,13 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        brelse(bh);
 
        if (sb->fs_start == -1) {
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
 
        bh = sb_bread(s, sb->fs_start + EFS_SUPER);
        if (!bh) {
                printk(KERN_ERR "EFS: cannot read superblock\n");
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
                
        if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
@@ -304,7 +303,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
                printk(KERN_WARNING "EFS: invalid superblock at block %u\n", sb->fs_start + EFS_SUPER);
 #endif
                brelse(bh);
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
        brelse(bh);
 
@@ -319,24 +318,16 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        root = efs_iget(s, EFS_ROOTINODE);
        if (IS_ERR(root)) {
                printk(KERN_ERR "EFS: get root inode failed\n");
-               ret = PTR_ERR(root);
-               goto out_no_fs;
+               return PTR_ERR(root);
        }
 
        s->s_root = d_make_root(root);
        if (!(s->s_root)) {
                printk(KERN_ERR "EFS: get root dentry failed\n");
-               ret = -ENOMEM;
-               goto out_no_fs;
+               return -ENOMEM;
        }
 
        return 0;
-
-out_no_fs_ul:
-out_no_fs:
-       s->s_fs_info = NULL;
-       kfree(sb);
-       return ret;
 }
 
 static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {