Skip to content

Commit

Permalink
efs: get rid of ->put_super()
Browse files Browse the repository at this point in the history
simplifies failure exits in ->mount()...

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jan 25, 2014
1 parent f7f4f4d commit 5a9ed6f
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions fs/efs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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,
};
Expand Down Expand Up @@ -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)
Expand All @@ -270,15 +269,15 @@ 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 */
bh = sb_bread(s, 0);

if (!bh) {
printk(KERN_ERR "EFS: cannot read volume header\n");
goto out_no_fs_ul;
return -EINVAL;
}

/*
Expand All @@ -290,21 +289,21 @@ 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)) {
#ifdef DEBUG
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);

Expand All @@ -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) {
Expand Down

0 comments on commit 5a9ed6f

Please sign in to comment.