struct super_block cleanup - ext2
Subsystems (2)
PATCH 1/1 struct super_block cleanup - ext2
First patch abstracts access to ext2_sb_info. Second patch completes the seperation.
Signature · 1 line
Brian Gerst
fs/ext2/balloc.c +12 -12
@@ -41,7 +41,7 @@unsigned long group_desc;unsigned long offset;struct ext2_group_desc * desc; -struct ext2_sb_info *sbi = &sb->u.ext2_sb; +struct ext2_sb_info *sbi =EXT2_SB (sb);if (block_group >= sbi->s_groups_count) { ext2_error (sb, "ext2_get_group_desc",
@@ -110,7 +110,7 @@static struct buffer_head *load_block_bitmap (struct super_block * sb,unsigned int block_group) { -struct ext2_sb_info *sbi = &sb->u.ext2_sb; +struct ext2_sb_info *sbi =EXT2_SB (sb);int i, slot =0 ;struct buffer_head *bh = sbi->s_block_bitmap[0 ];
@@ -249,7 +249,7 @@unsigned freed =0 , group_freed;lock_super (sb); - es = sb->u.ext2_sb.s_es; + es =EXT2_SB (sb)->s_es;if (block <le32_to_cpu (es->s_first_data_block) || (block + count) >le32_to_cpu (es->s_blocks_count)) { ext2_error (sb, "ext2_free_blocks",
@@ -285,9 +285,9 @@if (in_range (le32_to_cpu (desc->bg_block_bitmap), block, count) ||in_range (le32_to_cpu (desc->bg_inode_bitmap), block, count) ||in_range (block,le32_to_cpu (desc->bg_inode_table), - sb->u.ext2_sb.s_itb_per_group) || +EXT2_SB (sb)->s_itb_per_group) ||in_range (block + count -1 ,le32_to_cpu (desc->bg_inode_table), - sb->u.ext2_sb.s_itb_per_group)) +EXT2_SB (sb)->s_itb_per_group)) ext2_error (sb, "ext2_free_blocks", "Freeing blocks in system zones - " "Block = %lu, count = %lu",
@@ -552,11 +552,11 @@int i;lock_super (sb); - es = sb->u.ext2_sb.s_es; + es =EXT2_SB (sb)->s_es; desc_count =0 ; bitmap_count =0 ; desc =NULL ; -for (i =0 ; i < sb->u.ext2_sb.s_groups_count; i++) { +for (i =0 ; i <EXT2_SB (sb)->s_groups_count; i++) {struct buffer_head *bh; desc =ext2_get_group_desc (sb, i,NULL );if (!desc)
@@ -576,7 +576,7 @@unlock_super (sb);return bitmap_count;#else -return le32_to_cpu (sb->u.ext2_sb.s_es->s_free_blocks_count); +return le32_to_cpu (EXT2_SB (sb)->s_es->s_free_blocks_count);#endif }
@@ -584,7 +584,7 @@struct super_block * sb, unsigned char * map) { - return ext2_test_bit ((block - le32_to_cpu(sb->u.ext2_sb.s_es->s_first_data_block)) % + return ext2_test_bit ((block - le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block)) % EXT2_BLOCKS_PER_GROUP(sb), map); }
@@ -651,11 +651,11 @@struct ext2_group_desc * desc;int i; - es = sb->u.ext2_sb.s_es; + es =EXT2_SB (sb)->s_es; desc_count =0 ; bitmap_count =0 ; desc =NULL ; -for (i =0 ; i < sb->u.ext2_sb.s_groups_count; i++) { +for (i =0 ; i <EXT2_SB (sb)->s_groups_count; i++) { desc =ext2_get_group_desc (sb, i,NULL );if (!desc)continue ;
@@ -685,7 +685,7 @@"Inode bitmap for group %d is marked free" , i); -for (j =0 ; j < sb->u.ext2_sb.s_itb_per_group; j++) +for (j =0 ; j <EXT2_SB (sb)->s_itb_per_group; j++)if (!block_in_use (le32_to_cpu (desc->bg_inode_table) + j, sb, bh->b_data))ext2_error (sb,"ext2_check_blocks_bitmap" , "Block #%ld of the inode table in "
fs/ext2/dir.c +1 -1
@@ -68,7 +68,7 @@struct super_block *sb = dir->i_sb;unsigned chunk_size =ext2_chunk_size (dir);char *kaddr =page_address (page); -u32 max_inumber =le32_to_cpu (sb->u.ext2_sb.s_es->s_inodes_count); +u32 max_inumber =le32_to_cpu (EXT2_SB (sb)->s_es->s_inodes_count);unsigned offs, rec_len;unsigned limit =PAGE_CACHE_SIZE ;ext2_dirent *p;
fs/ext2/ialloc.c +14 -14
@@ -77,7 +77,7 @@ unsigned int block_group) {int i, slot =0 ; -struct ext2_sb_info *sbi = &sb->u.ext2_sb; +struct ext2_sb_info *sbi =EXT2_SB (sb);struct buffer_head *bh = sbi->s_inode_bitmap[0 ];if (block_group >= sbi->s_groups_count)
@@ -171,7 +171,7 @@ }lock_super (sb); - es = sb->u.ext2_sb.s_es; + es =EXT2_SB (sb)->s_es; is_directory =S_ISDIR (inode->i_mode);/* Do this BEFORE marking the inode not in use or returning an error */
@@ -205,7 +205,7 @@mark_buffer_dirty (bh2); es->s_free_inodes_count =cpu_to_le32 (le32_to_cpu (es->s_free_inodes_count) +1 ); -mark_buffer_dirty (sb->u.ext2_sb.s_sbh); +mark_buffer_dirty (EXT2_SB (sb)->s_sbh); }mark_buffer_dirty (bh);if (sb->s_flags &MS_SYNCHRONOUS ) {
@@ -230,8 +230,8 @@static int find_group_dir (struct super_block *sb,int parent_group) { -struct ext2_super_block * es = sb->u.ext2_sb.s_es; -int ngroups = sb->u.ext2_sb.s_groups_count; +struct ext2_super_block * es =EXT2_SB (sb)->s_es; +int ngroups =EXT2_SB (sb)->s_groups_count;int avefreei =le32_to_cpu (es->s_free_inodes_count) / ngroups;struct ext2_group_desc *desc, *best_desc =NULL ;struct buffer_head *bh, *best_bh =NULL ;
@@ -263,7 +263,7 @@static int find_group_other (struct super_block *sb,int parent_group) { -int ngroups = sb->u.ext2_sb.s_groups_count; +int ngroups =EXT2_SB (sb)->s_groups_count;struct ext2_group_desc *desc;struct buffer_head *bh;int group, i;
@@ -330,7 +330,7 @@ ei =EXT2_I (inode);lock_super (sb); - es = sb->u.ext2_sb.s_es; + es =EXT2_SB (sb)->s_es; repeat:if (S_ISDIR (mode)) group =find_group_dir (sb,EXT2_I (dir)->i_block_group);
@@ -369,7 +369,7 @@ es->s_free_inodes_count =cpu_to_le32 (le32_to_cpu (es->s_free_inodes_count) -1 ); -mark_buffer_dirty (sb->u.ext2_sb.s_sbh); +mark_buffer_dirty (EXT2_SB (sb)->s_sbh); sb->s_dirt =1 ; inode->i_uid = current->fsuid;if (test_opt (sb,GRPID ))
@@ -405,7 +405,7 @@ ei->i_dir_start_lookup =0 ;if (ei->i_flags &EXT2_SYNC_FL ) inode->i_flags |=S_SYNC ; - inode->i_generation = sb->u.ext2_sb.s_next_generation++; + inode->i_generation =EXT2_SB (sb)->s_next_generation++;insert_inode_hash (inode);mark_inode_dirty (inode);
@@ -457,8 +457,8 @@int i;lock_super (sb); - es = sb->u.ext2_sb.s_es; -for (i =0 ; i < sb->u.ext2_sb.s_groups_count; i++) { + es =EXT2_SB (sb)->s_es; +for (i =0 ; i <EXT2_SB (sb)->s_groups_count; i++) {struct ext2_group_desc *desc =ext2_get_group_desc (sb, i,NULL );struct buffer_head *bh;unsigned x;
@@ -480,7 +480,7 @@unlock_super (sb);return desc_count;#else -return le32_to_cpu (sb->u.ext2_sb.s_es->s_free_inodes_count); +return le32_to_cpu (EXT2_SB (sb)->s_es->s_free_inodes_count);#endif }
@@ -488,11 +488,11 @@/* Called at mount-time, super-block is locked */ void ext2_check_inodes_bitmap (struct super_block * sb) { -struct ext2_super_block * es = sb->u.ext2_sb.s_es; +struct ext2_super_block * es =EXT2_SB (sb)->s_es;unsigned long desc_count =0 , bitmap_count =0 ;int i; -for (i =0 ; i < sb->u.ext2_sb.s_groups_count; i++) { +for (i =0 ; i <EXT2_SB (sb)->s_groups_count; i++) {struct ext2_group_desc *desc =ext2_get_group_desc (sb, i,NULL );struct buffer_head *bh;unsigned x;
fs/ext2/inode.c +2 -2
@@ -303,7 +303,7 @@* the same cylinder group then. */ return (ei->i_block_group *EXT2_BLOCKS_PER_GROUP (inode->i_sb)) + -le32_to_cpu (inode->i_sb->u.ext2_sb.s_es->s_first_data_block); +le32_to_cpu (EXT2_SB (inode->i_sb)->s_es->s_first_data_block); }/**
@@ -886,7 +886,7 @@ *p =NULL ;if ((ino !=EXT2_ROOT_INO && ino !=EXT2_ACL_IDX_INO && ino !=EXT2_ACL_DATA_INO && ino <EXT2_FIRST_INO (sb)) || - ino >le32_to_cpu (sb->u.ext2_sb.s_es->s_inodes_count)) + ino >le32_to_cpu (EXT2_SB (sb)->s_es->s_inodes_count)) goto Einval; block_group = (ino -1 ) /EXT2_INODES_PER_GROUP (sb);
fs/ext2/super.c +115 -105
475 lines not on this page · raw message
fs/intermezzo/journal_ext2.c +3 -3
@@ -27,8 +27,8 @@static loff_t presto_e2_freespace (struct presto_cache *cache,struct super_block *sb) { -unsigned long freebl =le32_to_cpu (sb->u.ext2_sb.s_es->s_free_blocks_count); -unsigned long avail = freebl -le32_to_cpu (sb->u.ext2_sb.s_es->s_r_blocks_count); +unsigned long freebl =le32_to_cpu (EXT2_SB (sb)->s_es->s_free_blocks_count); +unsigned long avail = freebl -le32_to_cpu (EXT2_SB (sb)->s_es->s_r_blocks_count);return (avail <<EXT2_BLOCK_SIZE_BITS (sb)); }
@@ -41,7 +41,7 @@ strcmp(fset->fset_cache->cache_type, "ext2"))return NULL ; - avail_kmlblocks = inode->i_sb->u.ext2_sb.s_es->s_free_blocks_count; + avail_kmlblocks =EXT2_SB (inode->i_sb)->s_es->s_free_blocks_count;if ( avail_kmlblocks <3 ) {return ERR_PTR (-ENOSPC );
include/linux/ext2_fs.h +22 -19
77 lines not on this page · raw message
fs/ext2/super.c +14 -5
@@ -146,6 +146,8 @@if (sbi->s_block_bitmap[i])brelse (sbi->s_block_bitmap[i]);brelse (sbi->s_sbh); + sb->u.generic_sbp =NULL ; +kfree (sbi);return ; }
@@ -463,7 +465,11 @@int db_count;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 * use that as the blocksize. Otherwise (or if the blocksize
@@ -475,12 +481,12 @@ sbi->s_mount_opt =0 ;if (!parse_options ((char *) data, &sb_block, &resuid, &resgid, &sbi->s_mount_opt)) -return -EINVAL ; + goto failed_sbi; blocksize =sb_min_blocksize (sb,BLOCK_SIZE );if (!blocksize) {printk ("EXT2-fs: unable to set blocksize\n" ); -return -EINVAL ; + goto failed_sbi; }/*
@@ -495,7 +501,7 @@if (!(bh =sb_bread (sb, logic_sb_block))) {printk ("EXT2-fs: unable to read superblock\n" ); -return -EINVAL ; + goto failed_sbi; }/* * Note: s_es must be initialized as soon as possible because
@@ -541,7 +547,7 @@if (!sb_set_blocksize (sb, blocksize)) {printk (KERN_ERR "EXT2-fs: blocksize too small for device.\n" ); -return -EINVAL ; + goto failed_sbi; } logic_sb_block = (sb_block*BLOCK_SIZE ) / blocksize;
@@ -699,6 +705,9 @@kfree (sbi->s_group_desc); failed_mount:brelse (bh); +failed_sbi: + sb->u.generic_sbp =NULL ; +kfree (sbi);return -EINVAL ; }
include/linux/ext2_fs.h +2 -1
@@ -17,6 +17,7 @@#define _LINUX_EXT2_FS_H#include <linux/types.h> +#include <linux/ext2_fs_sb.h> /* * The second extended filesystem constants/structures
@@ -73,7 +74,7 @@#ifdef __KERNEL__static inline struct ext2_sb_info *EXT2_SB (struct super_block *sb) { -return &sb->u.ext2_sb; +return sb->u.generic_sbp; }#else /* Assume that user mode programs are passing in an ext2fs superblock, not
include/linux/fs.h +0 -2
@@ -648,7 +648,6 @@#define MNT_FORCE 0x00000001/* Attempt to forcibily umount */ #define MNT_DETACH 0x00000002/* Just detach from the tree */ -#include <linux/ext2_fs_sb.h> #include <linux/ext3_fs_sb.h> #include <linux/hpfs_fs_sb.h> #include <linux/ntfs_fs_sb.h>
@@ -704,7 +703,6 @@char s_id[32 ];/* Informational name */ union { -struct ext2_sb_info ext2_sb;struct ext3_sb_info ext3_sb;struct hpfs_sb_info hpfs_sb;struct ntfs_sb_info ntfs_sb;