Commit f7d5152e authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] struct super_block cleanup - ext2

Complete the ext2 superblock seperation.
parent 1b156290
...@@ -146,6 +146,8 @@ void ext2_put_super (struct super_block * sb) ...@@ -146,6 +146,8 @@ void ext2_put_super (struct super_block * sb)
if (sbi->s_block_bitmap[i]) if (sbi->s_block_bitmap[i])
brelse (sbi->s_block_bitmap[i]); brelse (sbi->s_block_bitmap[i]);
brelse (sbi->s_sbh); brelse (sbi->s_sbh);
sb->u.generic_sbp = NULL;
kfree(sbi);
return; return;
} }
...@@ -463,7 +465,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -463,7 +465,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
int db_count; int db_count;
int i, j; int i, j;
sbi = EXT2_SB(sb); sbi = kmalloc(sizeof(struct ext2_super_block), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->u.generic_sbp = sbi;
/* /*
* See what the current blocksize for the device is, and * See what the current blocksize for the device is, and
* use that as the blocksize. Otherwise (or if the blocksize * use that as the blocksize. Otherwise (or if the blocksize
...@@ -475,12 +481,12 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -475,12 +481,12 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_mount_opt = 0; sbi->s_mount_opt = 0;
if (!parse_options ((char *) data, &sb_block, &resuid, &resgid, if (!parse_options ((char *) data, &sb_block, &resuid, &resgid,
&sbi->s_mount_opt)) &sbi->s_mount_opt))
return -EINVAL; goto failed_sbi;
blocksize = sb_min_blocksize(sb, BLOCK_SIZE); blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
if (!blocksize) { if (!blocksize) {
printk ("EXT2-fs: unable to set blocksize\n"); printk ("EXT2-fs: unable to set blocksize\n");
return -EINVAL; goto failed_sbi;
} }
/* /*
...@@ -495,7 +501,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -495,7 +501,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!(bh = sb_bread(sb, logic_sb_block))) { if (!(bh = sb_bread(sb, logic_sb_block))) {
printk ("EXT2-fs: unable to read superblock\n"); printk ("EXT2-fs: unable to read superblock\n");
return -EINVAL; goto failed_sbi;
} }
/* /*
* Note: s_es must be initialized as soon as possible because * Note: s_es must be initialized as soon as possible because
...@@ -541,7 +547,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -541,7 +547,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!sb_set_blocksize(sb, blocksize)) { if (!sb_set_blocksize(sb, blocksize)) {
printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n"); printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
return -EINVAL; goto failed_sbi;
} }
logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize; logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
...@@ -699,6 +705,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -699,6 +705,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
kfree(sbi->s_group_desc); kfree(sbi->s_group_desc);
failed_mount: failed_mount:
brelse(bh); brelse(bh);
failed_sbi:
sb->u.generic_sbp = NULL;
kfree(sbi);
return -EINVAL; return -EINVAL;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define _LINUX_EXT2_FS_H #define _LINUX_EXT2_FS_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/ext2_fs_sb.h>
/* /*
* The second extended filesystem constants/structures * The second extended filesystem constants/structures
...@@ -73,7 +74,7 @@ ...@@ -73,7 +74,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb) static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
{ {
return &sb->u.ext2_sb; return sb->u.generic_sbp;
} }
#else #else
/* Assume that user mode programs are passing in an ext2fs superblock, not /* Assume that user mode programs are passing in an ext2fs superblock, not
......
...@@ -648,7 +648,6 @@ struct quota_mount_options ...@@ -648,7 +648,6 @@ struct quota_mount_options
#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */ #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
#define MNT_DETACH 0x00000002 /* Just detach from the tree */ #define MNT_DETACH 0x00000002 /* Just detach from the tree */
#include <linux/ext2_fs_sb.h>
#include <linux/ext3_fs_sb.h> #include <linux/ext3_fs_sb.h>
#include <linux/hpfs_fs_sb.h> #include <linux/hpfs_fs_sb.h>
#include <linux/ntfs_fs_sb.h> #include <linux/ntfs_fs_sb.h>
...@@ -703,7 +702,6 @@ struct super_block { ...@@ -703,7 +702,6 @@ struct super_block {
char s_id[32]; /* Informational name */ char s_id[32]; /* Informational name */
union { union {
struct ext2_sb_info ext2_sb;
struct ext3_sb_info ext3_sb; struct ext3_sb_info ext3_sb;
struct hpfs_sb_info hpfs_sb; struct hpfs_sb_info hpfs_sb;
struct ntfs_sb_info ntfs_sb; struct ntfs_sb_info ntfs_sb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment