From 5bb3575c7c93e3315df4123a2911ada821e757c2 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 17 Mar 2002 15:38:00 +0000 Subject: Remove jffs2_sb from struct super_block union. Remove FS_REQUIRES_DEV from JFFS2. We never really used the block device anyway. --- include/linux/fs.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/linux/fs.h') diff --git a/include/linux/fs.h b/include/linux/fs.h index f9f89afcb51e..d05052fa4461 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -658,7 +658,6 @@ struct quota_mount_options #include #include #include -#include extern struct list_head super_blocks; extern spinlock_t sb_lock; @@ -708,7 +707,6 @@ struct super_block { struct reiserfs_sb_info reiserfs_sb; struct bfs_sb_info bfs_sb; struct udf_sb_info udf_sb; - struct jffs2_sb_info jffs2_sb; void *generic_sbp; } u; /* -- cgit v1.2.3 From 7d42ccf3d8b273320cd05c850f9b41d79e3dfb96 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:38:35 -0800 Subject: [PATCH] struct super_block cleanup - isofs Seperates isofs_sb_info from struct super_block. --- fs/isofs/dir.c | 17 +++--- fs/isofs/inode.c | 157 ++++++++++++++++++++++++++----------------------- fs/isofs/joliet.c | 4 +- fs/isofs/namei.c | 13 ++-- fs/isofs/rock.c | 26 ++++---- include/linux/fs.h | 2 - include/linux/iso_fs.h | 7 ++- 7 files changed, 120 insertions(+), 106 deletions(-) (limited to 'include/linux/fs.h') diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index 583ade0421c0..bef27095249e 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c @@ -110,14 +110,13 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, struct buffer_head *bh = NULL; int len; int map; - int high_sierra; int first_de = 1; char *p = NULL; /* Quiet GCC */ struct iso_directory_record *de; + struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); offset = filp->f_pos & (bufsize - 1); block = filp->f_pos >> bufbits; - high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra; while (filp->f_pos < inode->i_size) { int de_len; @@ -166,7 +165,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, de = tmpde; } - if (de->flags[-high_sierra] & 0x80) { + if (de->flags[-sbi->s_high_sierra] & 0x80) { first_de = 0; filp->f_pos += de_len; continue; @@ -194,16 +193,16 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, /* Handle everything else. Do name translation if there is no Rock Ridge NM field. */ - if (inode->i_sb->u.isofs_sb.s_unhide == 'n') { + if (sbi->s_unhide == 'n') { /* Do not report hidden or associated files */ - if (de->flags[-high_sierra] & 5) { + if (de->flags[-sbi->s_high_sierra] & 5) { filp->f_pos += de_len; continue; } } map = 1; - if (inode->i_sb->u.isofs_sb.s_rock) { + if (sbi->s_rock) { len = get_rock_ridge_filename(de, tmpname, inode); if (len != 0) { /* may be -1 */ p = tmpname; @@ -212,16 +211,16 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, } if (map) { #ifdef CONFIG_JOLIET - if (inode->i_sb->u.isofs_sb.s_joliet_level) { + if (sbi->s_joliet_level) { len = get_joliet_filename(de, tmpname, inode); p = tmpname; } else #endif - if (inode->i_sb->u.isofs_sb.s_mapping == 'a') { + if (sbi->s_mapping == 'a') { len = get_acorn_filename(de, tmpname, inode); p = tmpname; } else - if (inode->i_sb->u.isofs_sb.s_mapping == 'n') { + if (sbi->s_mapping == 'n') { len = isofs_name_translate(de, tmpname, inode); p = tmpname; } else { diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index d1bec1eae0a0..31174ae2bede 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -60,10 +60,11 @@ static int isofs_dentry_cmp_ms(struct dentry *dentry, struct qstr *a, struct qst static void isofs_put_super(struct super_block *sb) { + struct isofs_sb_info *sbi = ISOFS_SB(sb); #ifdef CONFIG_JOLIET - if (sb->u.isofs_sb.s_nls_iocharset) { - unload_nls(sb->u.isofs_sb.s_nls_iocharset); - sb->u.isofs_sb.s_nls_iocharset = NULL; + if (sbi->s_nls_iocharset) { + unload_nls(sbi->s_nls_iocharset); + sbi->s_nls_iocharset = NULL; } #endif @@ -72,6 +73,8 @@ static void isofs_put_super(struct super_block *sb) check_malloc, check_bread); #endif + kfree(sbi); + sb->u.generic_sbp = NULL; return; } @@ -518,7 +521,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) struct iso_supplementary_descriptor *sec = NULL; struct iso_directory_record * rootp; int joliet_level = 0; - int high_sierra; int iso_blknum, block; int orig_zonesize; int table; @@ -526,9 +528,16 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) unsigned long first_data_zone; struct inode * inode; struct iso9660_options opt; + struct isofs_sb_info * sbi; + + sbi = kmalloc(sizeof(struct isofs_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + s->u.generic_sbp = sbi; + memset(sbi, 0, sizeof(struct isofs_sb_info)); if (!parse_options((char *) data, &opt)) - goto out_unlock; + goto out_freesbi; #if 0 printk("map = %c\n", opt.map); @@ -554,7 +563,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) */ opt.blocksize = sb_min_blocksize(s, opt.blocksize); - s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */ + sbi->s_high_sierra = 0; /* default is iso9660 */ vol_desc_start = (opt.sbsector != -1) ? opt.sbsector : isofs_get_last_session(s,opt.session); @@ -614,8 +623,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) if (isonum_711 (hdp->type) != ISO_VD_PRIMARY) goto out_freebh; - s->u.isofs_sb.s_high_sierra = 1; - high_sierra = 1; + sbi->s_high_sierra = 1; opt.rock = 'n'; h_pri = (struct hs_primary_descriptor *)vdp; goto root_found; @@ -646,29 +654,29 @@ root_found: pri = (struct iso_primary_descriptor *) sec; } - if(high_sierra){ + if(sbi->s_high_sierra){ rootp = (struct iso_directory_record *) h_pri->root_directory_record; #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS if (isonum_723 (h_pri->volume_set_size) != 1) goto out_no_support; #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */ - s->u.isofs_sb.s_nzones = isonum_733 (h_pri->volume_space_size); - s->u.isofs_sb.s_log_zone_size = isonum_723 (h_pri->logical_block_size); - s->u.isofs_sb.s_max_size = isonum_733(h_pri->volume_space_size); + sbi->s_nzones = isonum_733 (h_pri->volume_space_size); + sbi->s_log_zone_size = isonum_723 (h_pri->logical_block_size); + sbi->s_max_size = isonum_733(h_pri->volume_space_size); } else { rootp = (struct iso_directory_record *) pri->root_directory_record; #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS if (isonum_723 (pri->volume_set_size) != 1) goto out_no_support; #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */ - s->u.isofs_sb.s_nzones = isonum_733 (pri->volume_space_size); - s->u.isofs_sb.s_log_zone_size = isonum_723 (pri->logical_block_size); - s->u.isofs_sb.s_max_size = isonum_733(pri->volume_space_size); + sbi->s_nzones = isonum_733 (pri->volume_space_size); + sbi->s_log_zone_size = isonum_723 (pri->logical_block_size); + sbi->s_max_size = isonum_733(pri->volume_space_size); } - s->u.isofs_sb.s_ninodes = 0; /* No way to figure this out easily */ + sbi->s_ninodes = 0; /* No way to figure this out easily */ - orig_zonesize = s -> u.isofs_sb.s_log_zone_size; + orig_zonesize = sbi->s_log_zone_size; /* * If the zone size is smaller than the hardware sector size, * this is a fatal error. This would occur if the disc drive @@ -680,10 +688,10 @@ root_found: goto out_bad_size; /* RDE: convert log zone size to bit shift */ - switch (s -> u.isofs_sb.s_log_zone_size) - { case 512: s -> u.isofs_sb.s_log_zone_size = 9; break; - case 1024: s -> u.isofs_sb.s_log_zone_size = 10; break; - case 2048: s -> u.isofs_sb.s_log_zone_size = 11; break; + switch (sbi->s_log_zone_size) + { case 512: sbi->s_log_zone_size = 9; break; + case 1024: sbi->s_log_zone_size = 10; break; + case 2048: sbi->s_log_zone_size = 11; break; default: goto out_bad_zone_size; @@ -705,16 +713,16 @@ root_found: first_data_zone = ((isonum_733 (rootp->extent) + isonum_711 (rootp->ext_attr_length)) - << s -> u.isofs_sb.s_log_zone_size); - s->u.isofs_sb.s_firstdatazone = first_data_zone; + << sbi->s_log_zone_size); + sbi->s_firstdatazone = first_data_zone; #ifndef BEQUIET printk(KERN_DEBUG "Max size:%ld Log zone size:%ld\n", - s->u.isofs_sb.s_max_size, - 1UL << s->u.isofs_sb.s_log_zone_size); + sbi->s_max_size, + 1UL << sbi->s_log_zone_size); printk(KERN_DEBUG "First datazone:%ld Root inode number:%ld\n", - s->u.isofs_sb.s_firstdatazone >> s -> u.isofs_sb.s_log_zone_size, - s->u.isofs_sb.s_firstdatazone); - if(high_sierra) + sbi->s_firstdatazone >> sbi->s_log_zone_size, + sbi->s_firstdatazone); + if(sbi->s_high_sierra) printk(KERN_DEBUG "Disc in High Sierra format.\n"); #endif @@ -732,7 +740,7 @@ root_found: pri->root_directory_record; first_data_zone = ((isonum_733 (rootp->extent) + isonum_711 (rootp->ext_attr_length)) - << s -> u.isofs_sb.s_log_zone_size); + << sbi->s_log_zone_size); } /* @@ -761,43 +769,43 @@ root_found: */ sb_set_blocksize(s, orig_zonesize); - s->u.isofs_sb.s_nls_iocharset = NULL; + sbi->s_nls_iocharset = NULL; #ifdef CONFIG_JOLIET if (joliet_level && opt.utf8 == 0) { char * p = opt.iocharset ? opt.iocharset : "iso8859-1"; - s->u.isofs_sb.s_nls_iocharset = load_nls(p); - if (! s->u.isofs_sb.s_nls_iocharset) { + sbi->s_nls_iocharset = load_nls(p); + if (! sbi->s_nls_iocharset) { /* Fail only if explicit charset specified */ if (opt.iocharset) - goto out_unlock; - s->u.isofs_sb.s_nls_iocharset = load_nls_default(); + goto out_freesbi; + sbi->s_nls_iocharset = load_nls_default(); } } #endif s->s_op = &isofs_sops; - s->u.isofs_sb.s_mapping = opt.map; - s->u.isofs_sb.s_rock = (opt.rock == 'y' ? 2 : 0); - s->u.isofs_sb.s_rock_offset = -1; /* initial offset, will guess until SP is found*/ - s->u.isofs_sb.s_cruft = opt.cruft; - s->u.isofs_sb.s_unhide = opt.unhide; - s->u.isofs_sb.s_uid = opt.uid; - s->u.isofs_sb.s_gid = opt.gid; - s->u.isofs_sb.s_utf8 = opt.utf8; - s->u.isofs_sb.s_nocompress = opt.nocompress; + sbi->s_mapping = opt.map; + sbi->s_rock = (opt.rock == 'y' ? 2 : 0); + sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/ + sbi->s_cruft = opt.cruft; + sbi->s_unhide = opt.unhide; + sbi->s_uid = opt.uid; + sbi->s_gid = opt.gid; + sbi->s_utf8 = opt.utf8; + sbi->s_nocompress = opt.nocompress; /* * It would be incredibly stupid to allow people to mark every file * on the disk as suid, so we merely allow them to set the default * permissions. */ - s->u.isofs_sb.s_mode = opt.mode & 0777; + sbi->s_mode = opt.mode & 0777; /* * Read the root inode, which _may_ result in changing * the s_rock flag. Once we have the final s_rock value, * we then decide whether to use the Joliet descriptor. */ - inode = iget(s, s->u.isofs_sb.s_firstdatazone); + inode = iget(s, sbi->s_firstdatazone); /* * If this disk has both Rock Ridge and Joliet on it, then we @@ -807,16 +815,16 @@ root_found: * CD with Unicode names. Until someone sees such a beast, it * will not be supported. */ - if (s->u.isofs_sb.s_rock == 1) { + if (sbi->s_rock == 1) { joliet_level = 0; } else if (joliet_level) { - s->u.isofs_sb.s_rock = 0; - if (s->u.isofs_sb.s_firstdatazone != first_data_zone) { - s->u.isofs_sb.s_firstdatazone = first_data_zone; + sbi->s_rock = 0; + if (sbi->s_firstdatazone != first_data_zone) { + sbi->s_firstdatazone = first_data_zone; printk(KERN_DEBUG "ISOFS: changing to secondary root\n"); iput(inode); - inode = iget(s, s->u.isofs_sb.s_firstdatazone); + inode = iget(s, sbi->s_firstdatazone); } } @@ -825,7 +833,7 @@ root_found: if (joliet_level) opt.check = 'r'; else opt.check = 's'; } - s->u.isofs_sb.s_joliet_level = joliet_level; + sbi->s_joliet_level = joliet_level; /* check the root inode */ if (!inode) @@ -855,18 +863,18 @@ out_no_root: out_iput: iput(inode); #ifdef CONFIG_JOLIET - if (s->u.isofs_sb.s_nls_iocharset) - unload_nls(s->u.isofs_sb.s_nls_iocharset); + if (sbi->s_nls_iocharset) + unload_nls(sbi->s_nls_iocharset); #endif - goto out_unlock; + goto out_freesbi; out_no_read: printk(KERN_WARNING "isofs_fill_super: " "bread failed, dev=%s, iso_blknum=%d, block=%d\n", s->s_id, iso_blknum, block); - goto out_unlock; + goto out_freesbi; out_bad_zone_size: printk(KERN_WARNING "Bad logical zone size %ld\n", - s->u.isofs_sb.s_log_zone_size); + sbi->s_log_zone_size); goto out_freebh; out_bad_size: printk(KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n", @@ -883,7 +891,9 @@ out_unknown_format: out_freebh: brelse(bh); -out_unlock: +out_freesbi: + kfree(sbi); + s->u.generic_sbp = NULL; return -EINVAL; } @@ -891,11 +901,11 @@ static int isofs_statfs (struct super_block *sb, struct statfs *buf) { buf->f_type = ISOFS_SUPER_MAGIC; buf->f_bsize = sb->s_blocksize; - buf->f_blocks = (sb->u.isofs_sb.s_nzones - << (sb->u.isofs_sb.s_log_zone_size - sb->s_blocksize_bits)); + buf->f_blocks = (ISOFS_SB(sb)->s_nzones + << (ISOFS_SB(sb)->s_log_zone_size - sb->s_blocksize_bits)); buf->f_bfree = 0; buf->f_bavail = 0; - buf->f_files = sb->u.isofs_sb.s_ninodes; + buf->f_files = ISOFS_SB(sb)->s_ninodes; buf->f_ffree = 0; buf->f_namelen = NAME_MAX; return 0; @@ -1058,7 +1068,7 @@ static int isofs_read_level3_size(struct inode * inode) { unsigned long f_pos = inode->i_ino; unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); - int high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra; + int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; struct buffer_head * bh = NULL; unsigned long block, offset; int i = 0; @@ -1157,9 +1167,10 @@ out_toomany: static void isofs_read_inode(struct inode * inode) { struct super_block *sb = inode->i_sb; + struct isofs_sb_info *sbi = ISOFS_SB(sb); unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); int block = inode->i_ino >> ISOFS_BUFFER_BITS(inode); - int high_sierra = sb->u.isofs_sb.s_high_sierra; + int high_sierra = sbi->s_high_sierra; struct buffer_head * bh = NULL; struct iso_directory_record * de; struct iso_directory_record * tmpde = NULL; @@ -1205,7 +1216,7 @@ static void isofs_read_inode(struct inode * inode) do it the hard way. */ } else { /* Everybody gets to read the file. */ - inode->i_mode = inode->i_sb->u.isofs_sb.s_mode; + inode->i_mode = sbi->s_mode; inode->i_nlink = 1; inode->i_mode |= S_IFREG; /* If there are no periods in the name, @@ -1217,8 +1228,8 @@ static void isofs_read_inode(struct inode * inode) if(i == de->name_len[0] || de->name[i] == ';') inode->i_mode |= S_IXUGO; /* execute permission */ } - inode->i_uid = inode->i_sb->u.isofs_sb.s_uid; - inode->i_gid = inode->i_sb->u.isofs_sb.s_gid; + inode->i_uid = sbi->s_uid; + inode->i_gid = sbi->s_gid; inode->i_blocks = inode->i_blksize = 0; ei->i_format_parm[0] = 0; @@ -1241,10 +1252,10 @@ static void isofs_read_inode(struct inode * inode) * legal. Do not prevent to use DVD's schilling@fokus.gmd.de */ if ((inode->i_size < 0 || inode->i_size > 0x7FFFFFFE) && - inode->i_sb->u.isofs_sb.s_cruft == 'n') { + sbi->s_cruft == 'n') { printk(KERN_WARNING "Warning: defective CD-ROM. " "Enabling \"cruft\" mount option.\n"); - inode->i_sb->u.isofs_sb.s_cruft = 'y'; + sbi->s_cruft = 'y'; } /* @@ -1254,7 +1265,7 @@ static void isofs_read_inode(struct inode * inode) * on the CDROM. */ - if (inode->i_sb->u.isofs_sb.s_cruft == 'y' && + if (sbi->s_cruft == 'y' && inode->i_size & 0xff000000) { inode->i_size &= 0x00ffffff; } @@ -1298,8 +1309,8 @@ static void isofs_read_inode(struct inode * inode) if (!high_sierra) { parse_rock_ridge_inode(de, inode); /* if we want uid/gid set, override the rock ridge setting */ - test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid); - test_and_set_gid(&inode->i_gid, inode->i_sb->u.isofs_sb.s_gid); + test_and_set_uid(&inode->i_uid, sbi->s_uid); + test_and_set_gid(&inode->i_gid, sbi->s_gid); } /* get the volume sequence number */ @@ -1311,17 +1322,17 @@ static void isofs_read_inode(struct inode * inode) * of which is limiting the file size to 16Mb. Thus we silently allow * volume numbers of 0 to go through without complaining. */ - if (inode->i_sb->u.isofs_sb.s_cruft == 'n' && + if (sbi->s_cruft == 'n' && (volume_seq_no != 0) && (volume_seq_no != 1)) { printk(KERN_WARNING "Warning: defective CD-ROM " "(volume sequence number %d). " "Enabling \"cruft\" mount option.\n", volume_seq_no); - inode->i_sb->u.isofs_sb.s_cruft = 'y'; + sbi->s_cruft = 'y'; } /* Install the inode operations vector */ #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS - if (inode->i_sb->u.isofs_sb.s_cruft != 'y' && + if (sbi->s_cruft != 'y' && (volume_seq_no != 0) && (volume_seq_no != 1)) { printk(KERN_WARNING "Multi-volume CD somehow got mounted.\n"); } else diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c index 15d2370bda3f..86c50e22fc87 100644 --- a/fs/isofs/joliet.c +++ b/fs/isofs/joliet.c @@ -77,8 +77,8 @@ get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, st struct nls_table *nls; unsigned char len = 0; - utf8 = inode->i_sb->u.isofs_sb.s_utf8; - nls = inode->i_sb->u.isofs_sb.s_nls_iocharset; + utf8 = ISOFS_SB(inode->i_sb)->s_utf8; + nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; if (utf8) { len = wcsntombs_be(outname, de->name, diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index 485bb7023fe2..cbdf44b0164e 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c @@ -65,6 +65,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, unsigned char bufbits = ISOFS_BUFFER_BITS(dir); unsigned int block, f_pos, offset; struct buffer_head * bh = NULL; + struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb); if (!ISOFS_I(dir)->i_first_extent) return 0; @@ -120,19 +121,19 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, dlen = de->name_len[0]; dpnt = de->name; - if (dir->i_sb->u.isofs_sb.s_rock && + if (sbi->s_rock && ((i = get_rock_ridge_filename(de, tmpname, dir)))) { dlen = i; /* possibly -1 */ dpnt = tmpname; #ifdef CONFIG_JOLIET - } else if (dir->i_sb->u.isofs_sb.s_joliet_level) { + } else if (sbi->s_joliet_level) { dlen = get_joliet_filename(de, tmpname, dir); dpnt = tmpname; #endif - } else if (dir->i_sb->u.isofs_sb.s_mapping == 'a') { + } else if (sbi->s_mapping == 'a') { dlen = get_acorn_filename(de, tmpname, dir); dpnt = tmpname; - } else if (dir->i_sb->u.isofs_sb.s_mapping == 'n') { + } else if (sbi->s_mapping == 'n') { dlen = isofs_name_translate(de, tmpname, dir); dpnt = tmpname; } @@ -142,8 +143,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, */ match = 0; if (dlen > 0 && - (!(de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 5) - || dir->i_sb->u.isofs_sb.s_unhide == 'y')) + (!(de->flags[-sbi->s_high_sierra] & 5) + || sbi->s_unhide == 'y')) { match = (isofs_cmp(dentry,dpnt,dlen) == 0); } diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c index 5065d2fdccc6..17b2bb5e6908 100644 --- a/fs/isofs/rock.c +++ b/fs/isofs/rock.c @@ -32,7 +32,7 @@ #define CHECK_SP(FAIL) \ if(rr->u.SP.magic[0] != 0xbe) FAIL; \ if(rr->u.SP.magic[1] != 0xef) FAIL; \ - inode->i_sb->u.isofs_sb.s_rock_offset=rr->u.SP.skip; + ISOFS_SB(inode->i_sb)->s_rock_offset=rr->u.SP.skip; /* We define a series of macros because each function must do exactly the same thing in certain places. We use the macros to ensure that everything is done correctly */ @@ -51,10 +51,10 @@ if(LEN & 1) LEN++; \ CHR = ((unsigned char *) DE) + LEN; \ LEN = *((unsigned char *) DE) - LEN; \ - if (inode->i_sb->u.isofs_sb.s_rock_offset!=-1) \ + if (ISOFS_SB(inode->i_sb)->s_rock_offset!=-1) \ { \ - LEN-=inode->i_sb->u.isofs_sb.s_rock_offset; \ - CHR+=inode->i_sb->u.isofs_sb.s_rock_offset; \ + LEN-=ISOFS_SB(inode->i_sb)->s_rock_offset; \ + CHR+=ISOFS_SB(inode->i_sb)->s_rock_offset; \ if (LEN<0) LEN=0; \ } \ } @@ -102,7 +102,7 @@ int find_rock_ridge_relocation(struct iso_directory_record * de, /* Return value if we do not find appropriate record. */ retval = isonum_733 (de->extent); - if (!inode->i_sb->u.isofs_sb.s_rock) return retval; + if (!ISOFS_SB(inode->i_sb)->s_rock) return retval; SETUP_ROCK_RIDGE(de, chr, len); repeat: @@ -162,7 +162,7 @@ int get_rock_ridge_filename(struct iso_directory_record * de, CONTINUE_DECLS; int retnamlen = 0, truncate=0; - if (!inode->i_sb->u.isofs_sb.s_rock) return 0; + if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; *retname = 0; SETUP_ROCK_RIDGE(de, chr, len); @@ -234,7 +234,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, int symlink_len = 0; CONTINUE_DECLS; - if (!inode->i_sb->u.isofs_sb.s_rock) return 0; + if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; SETUP_ROCK_RIDGE(de, chr, len); if (regard_xa) @@ -272,7 +272,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, CHECK_CE; break; case SIG('E','R'): - inode->i_sb->u.isofs_sb.s_rock = 1; + ISOFS_SB(inode->i_sb)->s_rock = 1; printk(KERN_DEBUG "ISO 9660 Extensions: "); { int p; for(p=0;pu.ER.len_id;p++) printk("%c",rr->u.ER.data[p]); @@ -368,7 +368,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, ISOFS_I(inode)->i_first_extent = isonum_733(rr->u.CL.location); reloc = iget(inode->i_sb, (ISOFS_I(inode)->i_first_extent << - inode -> i_sb -> u.isofs_sb.s_log_zone_size)); + ISOFS_SB(inode->i_sb)->s_log_zone_size)); if (!reloc) goto out; inode->i_mode = reloc->i_mode; @@ -385,7 +385,7 @@ int parse_rock_ridge_inode_internal(struct iso_directory_record * de, break; #ifdef CONFIG_ZISOFS case SIG('Z','F'): - if ( !inode->i_sb->u.isofs_sb.s_nocompress ) { + if ( !ISOFS_SB(inode->i_sb)->s_nocompress ) { int algo; algo = isonum_721(rr->u.ZF.algorithm); if ( algo == SIG('p','z') ) { @@ -478,8 +478,8 @@ int parse_rock_ridge_inode(struct iso_directory_record * de, int result=parse_rock_ridge_inode_internal(de,inode,0); /* if rockridge flag was reset and we didn't look for attributes * behind eventual XA attributes, have a look there */ - if ((inode->i_sb->u.isofs_sb.s_rock_offset==-1) - &&(inode->i_sb->u.isofs_sb.s_rock==2)) + if ((ISOFS_SB(inode->i_sb)->s_rock_offset==-1) + &&(ISOFS_SB(inode->i_sb)->s_rock==2)) { result=parse_rock_ridge_inode_internal(de,inode,14); }; @@ -506,7 +506,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page) unsigned char *chr; struct rock_ridge *rr; - if (!inode->i_sb->u.isofs_sb.s_rock) + if (!ISOFS_SB(inode->i_sb)->s_rock) panic ("Cannot have symlink with high sierra variant of iso filesystem\n"); block = inode->i_ino >> bufbits; diff --git a/include/linux/fs.h b/include/linux/fs.h index f9f89afcb51e..f303f619b559 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -648,7 +648,6 @@ struct quota_mount_options #include #include #include -#include #include #include #include @@ -697,7 +696,6 @@ struct super_block { struct ext3_sb_info ext3_sb; struct hpfs_sb_info hpfs_sb; struct ntfs_sb_info ntfs_sb; - struct isofs_sb_info isofs_sb; struct sysv_sb_info sysv_sb; struct affs_sb_info affs_sb; struct ufs_sb_info ufs_sb; diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h index b235c3ea9f23..3520e22a2af8 100644 --- a/include/linux/iso_fs.h +++ b/include/linux/iso_fs.h @@ -160,7 +160,6 @@ struct iso_directory_record { #define ISOFS_BUFFER_SIZE(INODE) ((INODE)->i_sb->s_blocksize) #define ISOFS_BUFFER_BITS(INODE) ((INODE)->i_sb->s_blocksize_bits) -#define ISOFS_ZONE_BITS(INODE) ((INODE)->i_sb->u.isofs_sb.s_log_zone_size) #define ISOFS_SUPER_MAGIC 0x9660 @@ -171,6 +170,12 @@ struct iso_directory_record { #include #include #include +#include + +static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} static inline struct iso_inode_info *ISOFS_I(struct inode *inode) { -- cgit v1.2.3 From 2703321515d8d73771236f78f8fb721103a1494f Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:38:40 -0800 Subject: [PATCH] struct super_block cleanup - udf Seperates udf_sb_info from struct super_block. --- fs/udf/super.c | 9 +++++++++ fs/udf/udf_sb.h | 6 +++++- fs/udf/udfdecl.h | 4 ++-- include/linux/fs.h | 2 -- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'include/linux/fs.h') diff --git a/fs/udf/super.c b/fs/udf/super.c index 0e668a01a592..2edd4015fb61 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1413,12 +1413,17 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) struct inode *inode=NULL; struct udf_options uopt; lb_addr rootdir, fileset; + struct udf_sb_info *sbi; uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); uopt.uid = -1; uopt.gid = -1; uopt.umask = 0; + sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + sb->u.generic_sbp = sbi; memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); #if UDFFS_RW != 1 @@ -1607,6 +1612,8 @@ error_out: udf_close_lvid(sb); udf_release_data(UDF_SB_LVIDBH(sb)); UDF_SB_FREE(sb); + kfree(sbi); + sb->u.generic_sbp = NULL; return -EINVAL; } @@ -1697,6 +1704,8 @@ udf_put_super(struct super_block *sb) udf_close_lvid(sb); udf_release_data(UDF_SB_LVIDBH(sb)); UDF_SB_FREE(sb); + kfree(sb->u.generic_sbp); + sb->u.generic_sbp = NULL; } /* diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 0dde99415c97..2b264e1cf49a 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -30,6 +30,11 @@ #define UDF_PART_FLAG_REWRITABLE 0x0040 #define UDF_PART_FLAG_OVERWRITABLE 0x0080 +static inline struct udf_sb_info *UDF_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} + #define UDF_SB_FREE(X)\ {\ if (UDF_SB(X))\ @@ -39,7 +44,6 @@ UDF_SB_PARTMAPS(X) = NULL;\ }\ } -#define UDF_SB(X) (&((X)->u.udf_sb)) #define UDF_SB_ALLOC_PARTMAPS(X,Y)\ {\ diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 836aef50cded..1b4d5a5d1401 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #ifndef LINUX_VERSION_CODE #include @@ -15,8 +17,6 @@ #if !defined(CONFIG_UDF_FS) && !defined(CONFIG_UDF_FS_MODULE) #define CONFIG_UDF_FS_MODULE -#include -#include #endif #include "udfend.h" diff --git a/include/linux/fs.h b/include/linux/fs.h index f303f619b559..c8651e089379 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -656,7 +656,6 @@ struct quota_mount_options #include #include #include -#include #include extern struct list_head super_blocks; @@ -705,7 +704,6 @@ struct super_block { struct adfs_sb_info adfs_sb; struct reiserfs_sb_info reiserfs_sb; struct bfs_sb_info bfs_sb; - struct udf_sb_info udf_sb; struct jffs2_sb_info jffs2_sb; void *generic_sbp; } u; -- cgit v1.2.3 From 4758c319c0967b4356c8894a8f4f2b93e68a803b Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:48:42 -0800 Subject: [PATCH] struct super_block cleanup - shmem Seperates shmem_sb_info from struct super_block. --- include/linux/fs.h | 2 -- ipc/shm.c | 1 + mm/shmem.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 39 insertions(+), 11 deletions(-) (limited to 'include/linux/fs.h') diff --git a/include/linux/fs.h b/include/linux/fs.h index 1600f74d5410..cab76452160c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -471,7 +471,6 @@ static inline struct inode *SOCK_INODE(struct socket *socket) return &list_entry(socket, struct socket_alloc, socket)->vfs_inode; } -#include /* will die */ #include #include @@ -697,7 +696,6 @@ struct super_block { struct sysv_sb_info sysv_sb; struct affs_sb_info affs_sb; struct ufs_sb_info ufs_sb; - struct shmem_sb_info shmem_sb; struct romfs_sb_info romfs_sb; struct hfs_sb_info hfs_sb; struct adfs_sb_info adfs_sb; diff --git a/ipc/shm.c b/ipc/shm.c index 7a1335327179..6d7f6b364294 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "util.h" diff --git a/mm/shmem.c b/mm/shmem.c index b230b331b462..b2b19b905116 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -36,7 +37,10 @@ #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long)) -#define SHMEM_SB(sb) (&sb->u.shmem_sb) +static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} static struct super_operations shmem_ops; static struct address_space_operations shmem_aops; @@ -1261,7 +1265,7 @@ bad_val: static int shmem_remount_fs (struct super_block *sb, int *flags, char *data) { - struct shmem_sb_info *sbinfo = &sb->u.shmem_sb; + struct shmem_sb_info *sbinfo = SHMEM_SB(sb); unsigned long max_blocks = sbinfo->max_blocks; unsigned long max_inodes = sbinfo->max_inodes; @@ -1284,8 +1288,15 @@ static int shmem_fill_super(struct super_block * sb, void * data, int silent) int mode = S_IRWXUGO | S_ISVTX; uid_t uid = current->fsuid; gid_t gid = current->fsgid; - struct shmem_sb_info *sbinfo = SHMEM_SB(sb); + struct shmem_sb_info *sbinfo; struct sysinfo si; + int err; + + sbinfo = kmalloc(sizeof(struct shmem_sb_info), GFP_KERNEL); + if (!sbinfo) + return -ENOMEM; + sb->u.generic_sbp = sbinfo; + memset(sbinfo, 0, sizeof(struct shmem_sb_info)); /* * Per default we only allow half of the physical ram per @@ -1295,8 +1306,10 @@ static int shmem_fill_super(struct super_block * sb, void * data, int silent) blocks = inodes = si.totalram / 2; #ifdef CONFIG_TMPFS - if (shmem_parse_options (data, &mode, &uid, &gid, &blocks, &inodes)) - return -EINVAL; + if (shmem_parse_options (data, &mode, &uid, &gid, &blocks, &inodes)) { + err = -EINVAL; + goto failed; + } #endif spin_lock_init (&sbinfo->stat_lock); @@ -1310,18 +1323,33 @@ static int shmem_fill_super(struct super_block * sb, void * data, int silent) sb->s_magic = TMPFS_MAGIC; sb->s_op = &shmem_ops; inode = shmem_get_inode(sb, S_IFDIR | mode, 0); - if (!inode) - return -ENOMEM; + if (!inode) { + err = -ENOMEM; + goto failed; + } inode->i_uid = uid; inode->i_gid = gid; root = d_alloc_root(inode); if (!root) { - iput(inode); - return -ENOMEM; + err = -ENOMEM; + goto failed_iput; } sb->s_root = root; return 0; + +failed_iput: + iput(inode); +failed: + kfree(sbinfo); + sb->u.generic_sbp = NULL; + return err; +} + +static void shmem_put_super(struct super_block *sb) +{ + kfree(sb->u.generic_sbp); + sb->u.generic_sbp = NULL; } static kmem_cache_t * shmem_inode_cachep; @@ -1407,6 +1435,7 @@ static struct super_operations shmem_ops = { #endif delete_inode: shmem_delete_inode, put_inode: force_delete, + put_super: shmem_put_super, }; static struct vm_operations_struct shmem_vm_ops = { -- cgit v1.2.3 From e368ea0bd61d20246c2351014df9464140840c55 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:49:31 -0800 Subject: [PATCH] struct super_block cleanup - hfs Seperates hfs_sb_info from struct super_block. --- fs/hfs/super.c | 16 ++++++++++++++-- include/linux/fs.h | 2 -- include/linux/hfs_fs.h | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'include/linux/fs.h') diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 5330f3325da6..934310f4f35c 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c @@ -178,6 +178,9 @@ static void hfs_put_super(struct super_block *sb) /* restore default blocksize for the device */ set_blocksize(sb->s_dev, BLOCK_SIZE); + + kfree(sb->u.generic_sbp); + sb->u.generic_sbp = NULL; } /* @@ -443,6 +446,7 @@ done: */ int hfs_fill_super(struct super_block *s, void *data, int silent) { + struct hfs_sb_info *sbi; struct hfs_mdb *mdb; struct hfs_cat_key key; kdev_t dev = s->s_dev; @@ -450,7 +454,13 @@ int hfs_fill_super(struct super_block *s, void *data, int silent) struct inode *root_inode; int part; - if (!parse_options((char *)data, HFS_SB(s), &part)) { + sbi = kmalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + s->u.generic_sbp = sbi; + memset(sbi, 0, sizeof(struct hfs_sb_info)); + + if (!parse_options((char *)data, sbi, &part)) { hfs_warn("hfs_fs: unable to parse mount options.\n"); goto bail3; } @@ -485,7 +495,7 @@ int hfs_fill_super(struct super_block *s, void *data, int silent) goto bail2; } - HFS_SB(s)->s_mdb = mdb; + sbi->s_mdb = mdb; if (HFS_ITYPE(mdb->next_id) != 0) { hfs_warn("hfs_fs: too many files.\n"); goto bail1; @@ -522,6 +532,8 @@ bail1: bail2: set_blocksize(dev, BLOCK_SIZE); bail3: + kfree(sbi); + sb->u.generic_sbp = NULL; return -EINVAL; } diff --git a/include/linux/fs.h b/include/linux/fs.h index cab76452160c..a1ae91bafcfc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -651,7 +651,6 @@ struct quota_mount_options #include #include #include -#include #include #include #include @@ -697,7 +696,6 @@ struct super_block { struct affs_sb_info affs_sb; struct ufs_sb_info ufs_sb; struct romfs_sb_info romfs_sb; - struct hfs_sb_info hfs_sb; struct adfs_sb_info adfs_sb; struct reiserfs_sb_info reiserfs_sb; struct bfs_sb_info bfs_sb; diff --git a/include/linux/hfs_fs.h b/include/linux/hfs_fs.h index f6272708f041..c0acee5f5f4b 100644 --- a/include/linux/hfs_fs.h +++ b/include/linux/hfs_fs.h @@ -318,12 +318,17 @@ extern int hfs_mac2triv(char *, const struct hfs_name *); extern void hfs_tolower(unsigned char *, int); #include +#include static inline struct hfs_inode_info *HFS_I(struct inode *inode) { return list_entry(inode, struct hfs_inode_info, vfs_inode); } -#define HFS_SB(X) (&((X)->u.hfs_sb)) + +static inline struct hfs_sb_info *HFS_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} static inline void hfs_nameout(struct inode *dir, struct hfs_name *out, const char *in, int len) { -- cgit v1.2.3 From fe3c92394eecb71595f3268d83f15501c274472d Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 17 Mar 2002 18:50:03 -0800 Subject: [PATCH] struct super_block cleanup - affs Seperates affs_sb_info from struct super_block. --- fs/affs/amigaffs.c | 4 +- fs/affs/bitmap.c | 108 +++++++++++++++++++------------------ fs/affs/dir.c | 2 +- fs/affs/file.c | 22 ++++---- fs/affs/inode.c | 45 ++++++++-------- fs/affs/namei.c | 14 ++--- fs/affs/super.c | 130 +++++++++++++++++++++++++-------------------- fs/affs/symlink.c | 2 +- include/linux/affs_fs.h | 1 + include/linux/affs_fs_sb.h | 5 +- include/linux/amigaffs.h | 10 ++-- include/linux/fs.h | 2 - 12 files changed, 183 insertions(+), 162 deletions(-) (limited to 'include/linux/fs.h') diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index d0532a67af60..bc229488cfbf 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c @@ -246,7 +246,7 @@ affs_empty_dir(struct inode *inode) goto done; retval = -ENOTEMPTY; - for (size = AFFS_SB->s_hashsize - 1; size >= 0; size--) + for (size = AFFS_SB(sb)->s_hashsize - 1; size >= 0; size--) if (AFFS_HEAD(bh)->table[size]) goto not_empty; retval = 0; @@ -458,7 +458,7 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...) if (!(sb->s_flags & MS_RDONLY)) printk(KERN_WARNING "AFFS: Remounting filesystem read-only\n"); sb->s_flags |= MS_RDONLY; - AFFS_SB->s_flags |= SF_READONLY; /* Don't allow to remount rw */ + AFFS_SB(sb)->s_flags |= SF_READONLY; /* Don't allow to remount rw */ } void diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index 1726db8a09a8..c0e48f698ee7 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c @@ -53,14 +53,14 @@ affs_count_free_blocks(struct super_block *sb) if (sb->s_flags & MS_RDONLY) return 0; - down(&AFFS_SB->s_bmlock); + down(&AFFS_SB(sb)->s_bmlock); - bm = AFFS_SB->s_bitmap; + bm = AFFS_SB(sb)->s_bitmap; free = 0; - for (i = AFFS_SB->s_bmap_count; i > 0; bm++, i--) + for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) free += bm->bm_free; - up(&AFFS_SB->s_bmlock); + up(&AFFS_SB(sb)->s_bmlock); return free; } @@ -68,6 +68,7 @@ affs_count_free_blocks(struct super_block *sb) void affs_free_block(struct super_block *sb, u32 block) { + struct affs_sb_info *sbi = AFFS_SB(sb); struct affs_bm_info *bm; struct buffer_head *bh; u32 blk, bmap, bit, mask, tmp; @@ -75,24 +76,24 @@ affs_free_block(struct super_block *sb, u32 block) pr_debug("AFFS: free_block(%u)\n", block); - if (block > AFFS_SB->s_partition_size) + if (block > sbi->s_partition_size) goto err_range; - blk = block - AFFS_SB->s_reserved; - bmap = blk / AFFS_SB->s_bmap_bits; - bit = blk % AFFS_SB->s_bmap_bits; - bm = &AFFS_SB->s_bitmap[bmap]; + blk = block - sbi->s_reserved; + bmap = blk / sbi->s_bmap_bits; + bit = blk % sbi->s_bmap_bits; + bm = &sbi->s_bitmap[bmap]; - down(&AFFS_SB->s_bmlock); + down(&sbi->s_bmlock); - bh = AFFS_SB->s_bmap_bh; - if (AFFS_SB->s_last_bmap != bmap) { + bh = sbi->s_bmap_bh; + if (sbi->s_last_bmap != bmap) { affs_brelse(bh); bh = affs_bread(sb, bm->bm_key); if (!bh) goto err_bh_read; - AFFS_SB->s_bmap_bh = bh; - AFFS_SB->s_last_bmap = bmap; + sbi->s_bmap_bh = bh; + sbi->s_last_bmap = bmap; } mask = 1 << (bit & 31); @@ -112,19 +113,19 @@ affs_free_block(struct super_block *sb, u32 block) sb->s_dirt = 1; bm->bm_free++; - up(&AFFS_SB->s_bmlock); + up(&sbi->s_bmlock); return; err_free: affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); - up(&AFFS_SB->s_bmlock); + up(&sbi->s_bmlock); return; err_bh_read: affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); - AFFS_SB->s_bmap_bh = NULL; - AFFS_SB->s_last_bmap = ~0; - up(&AFFS_SB->s_bmlock); + sbi->s_bmap_bh = NULL; + sbi->s_last_bmap = ~0; + up(&sbi->s_bmlock); return; err_range: @@ -145,6 +146,7 @@ u32 affs_alloc_block(struct inode *inode, u32 goal) { struct super_block *sb; + struct affs_sb_info *sbi; struct affs_bm_info *bm; struct buffer_head *bh; u32 *data, *enddata; @@ -152,6 +154,7 @@ affs_alloc_block(struct inode *inode, u32 goal) int i; sb = inode->i_sb; + sbi = AFFS_SB(sb); pr_debug("AFFS: balloc(inode=%lu,goal=%u): ", inode->i_ino, goal); @@ -161,53 +164,53 @@ affs_alloc_block(struct inode *inode, u32 goal) return ++AFFS_I(inode)->i_lastalloc; } - if (!goal || goal > AFFS_SB->s_partition_size) { + if (!goal || goal > sbi->s_partition_size) { if (goal) affs_warning(sb, "affs_balloc", "invalid goal %d", goal); //if (!AFFS_I(inode)->i_last_block) // affs_warning(sb, "affs_balloc", "no last alloc block"); - goal = AFFS_SB->s_reserved; + goal = sbi->s_reserved; } - blk = goal - AFFS_SB->s_reserved; - bmap = blk / AFFS_SB->s_bmap_bits; - bm = &AFFS_SB->s_bitmap[bmap]; + blk = goal - sbi->s_reserved; + bmap = blk / sbi->s_bmap_bits; + bm = &sbi->s_bitmap[bmap]; - down(&AFFS_SB->s_bmlock); + down(&sbi->s_bmlock); if (bm->bm_free) goto find_bmap_bit; find_bmap: /* search for the next bmap buffer with free bits */ - i = AFFS_SB->s_bmap_count; + i = sbi->s_bmap_count; do { bmap++; bm++; - if (bmap < AFFS_SB->s_bmap_count) + if (bmap < sbi->s_bmap_count) continue; /* restart search at zero */ bmap = 0; - bm = AFFS_SB->s_bitmap; + bm = sbi->s_bitmap; if (--i <= 0) goto err_full; } while (!bm->bm_free); - blk = bmap * AFFS_SB->s_bmap_bits; + blk = bmap * sbi->s_bmap_bits; find_bmap_bit: - bh = AFFS_SB->s_bmap_bh; - if (AFFS_SB->s_last_bmap != bmap) { + bh = sbi->s_bmap_bh; + if (sbi->s_last_bmap != bmap) { affs_brelse(bh); bh = affs_bread(sb, bm->bm_key); if (!bh) goto err_bh_read; - AFFS_SB->s_bmap_bh = bh; - AFFS_SB->s_last_bmap = bmap; + sbi->s_bmap_bh = bh; + sbi->s_last_bmap = bmap; } /* find an unused block in this bitmap block */ - bit = blk % AFFS_SB->s_bmap_bits; + bit = blk % sbi->s_bmap_bits; data = (u32 *)bh->b_data + bit / 32 + 1; enddata = (u32 *)((u8 *)bh->b_data + sb->s_blocksize); mask = ~0UL << (bit & 31); @@ -231,7 +234,7 @@ find_bmap_bit: find_bit: /* finally look for a free bit in the word */ bit = ffs(tmp) - 1; - blk += bit + AFFS_SB->s_reserved; + blk += bit + sbi->s_reserved; mask2 = mask = 1 << (bit & 31); AFFS_I(inode)->i_lastalloc = blk; @@ -253,18 +256,18 @@ find_bit: mark_buffer_dirty(bh); sb->s_dirt = 1; - up(&AFFS_SB->s_bmlock); + up(&sbi->s_bmlock); pr_debug("%d\n", blk); return blk; err_bh_read: affs_error(sb,"affs_read_block","Cannot read bitmap block %u", bm->bm_key); - AFFS_SB->s_bmap_bh = NULL; - AFFS_SB->s_last_bmap = ~0; + sbi->s_bmap_bh = NULL; + sbi->s_last_bmap = ~0; err_full: pr_debug("failed\n"); - up(&AFFS_SB->s_bmlock); + up(&sbi->s_bmlock); return 0; } @@ -276,35 +279,36 @@ affs_init_bitmap(struct super_block *sb) u32 *bmap_blk; u32 size, blk, end, offset, mask; int i, res = 0; + struct affs_sb_info *sbi = AFFS_SB(sb); if (sb->s_flags & MS_RDONLY) return 0; - if (!AFFS_ROOT_TAIL(sb, AFFS_SB->s_root_bh)->bm_flag) { + if (!AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag) { printk(KERN_NOTICE "AFFS: Bitmap invalid - mounting %s read only\n", sb->s_id); sb->s_flags |= MS_RDONLY; return 0; } - AFFS_SB->s_last_bmap = ~0; - AFFS_SB->s_bmap_bh = NULL; - AFFS_SB->s_bmap_bits = sb->s_blocksize * 8 - 32; - AFFS_SB->s_bmap_count = (AFFS_SB->s_partition_size - AFFS_SB->s_reserved + - AFFS_SB->s_bmap_bits - 1) / AFFS_SB->s_bmap_bits; - size = AFFS_SB->s_bmap_count * sizeof(struct affs_bm_info); - bm = AFFS_SB->s_bitmap = kmalloc(size, GFP_KERNEL); - if (!AFFS_SB->s_bitmap) { + sbi->s_last_bmap = ~0; + sbi->s_bmap_bh = NULL; + sbi->s_bmap_bits = sb->s_blocksize * 8 - 32; + sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved + + sbi->s_bmap_bits - 1) / sbi->s_bmap_bits; + size = sbi->s_bmap_count * sizeof(struct affs_bm_info); + bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL); + if (!sbi->s_bitmap) { printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); return 1; } - memset(AFFS_SB->s_bitmap, 0, size); + memset(sbi->s_bitmap, 0, size); - bmap_blk = (u32 *)AFFS_SB->s_root_bh->b_data; + bmap_blk = (u32 *)sbi->s_root_bh->b_data; blk = sb->s_blocksize / 4 - 49; end = blk + 25; - for (i = AFFS_SB->s_bmap_count; i > 0; bm++, i--) { + for (i = sbi->s_bmap_count; i > 0; bm++, i--) { affs_brelse(bh); bm->bm_key = be32_to_cpu(bmap_blk[blk]); @@ -341,7 +345,7 @@ affs_init_bitmap(struct super_block *sb) end = sb->s_blocksize / 4 - 1; } - offset = (AFFS_SB->s_partition_size - AFFS_SB->s_reserved) % AFFS_SB->s_bmap_bits; + offset = (sbi->s_partition_size - sbi->s_reserved) % sbi->s_bmap_bits; mask = ~(0xFFFFFFFFU << (offset & 31)); pr_debug("last word: %d %d %d\n", offset, offset / 32 + 1, mask); offset = offset / 32 + 1; diff --git a/fs/affs/dir.c b/fs/affs/dir.c index 460f8926d102..aa69197ba0ab 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -122,7 +122,7 @@ affs_readdir(struct file *filp, void *dirent, filldir_t filldir) goto inside; hash_pos++; - for (; hash_pos < AFFS_SB->s_hashsize; hash_pos++) { + for (; hash_pos < AFFS_SB(sb)->s_hashsize; hash_pos++) { ino = be32_to_cpu(AFFS_HEAD(dir_bh)->table[hash_pos]); if (!ino) continue; diff --git a/fs/affs/file.c b/fs/affs/file.c index 4d7d470d209a..465d34cede28 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -350,8 +350,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul //lock cache affs_lock_ext(inode); - ext = block / AFFS_SB->s_hashsize; - block -= ext * AFFS_SB->s_hashsize; + ext = block / AFFS_SB(sb)->s_hashsize; + block -= ext * AFFS_SB(sb)->s_hashsize; ext_bh = affs_get_extblock(inode, ext); if (IS_ERR(ext_bh)) goto err_ext; @@ -362,7 +362,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul if (!blocknr) goto err_alloc; bh_result->b_state |= (1UL << BH_New); - AFFS_I(inode)->mmu_private += AFFS_SB->s_data_blksize; + AFFS_I(inode)->mmu_private += AFFS_SB(sb)->s_data_blksize; AFFS_I(inode)->i_blkcnt++; /* store new block */ @@ -516,7 +516,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); data = page_address(page); - bsize = AFFS_SB->s_data_blksize; + bsize = AFFS_SB(sb)->s_data_blksize; tmp = (page->index << PAGE_CACHE_SHIFT) + from; bidx = tmp / bsize; boff = tmp % bsize; @@ -546,7 +546,7 @@ affs_extent_file_ofs(struct file *file, u32 newsize) u32 tmp; pr_debug("AFFS: extent_file(%u, %d)\n", (u32)inode->i_ino, newsize); - bsize = AFFS_SB->s_data_blksize; + bsize = AFFS_SB(sb)->s_data_blksize; bh = NULL; size = inode->i_size; bidx = size / bsize; @@ -670,7 +670,7 @@ static int affs_commit_write_ofs(struct file *file, struct page *page, unsigned int written; pr_debug("AFFS: commit_write(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); - bsize = AFFS_SB->s_data_blksize; + bsize = AFFS_SB(sb)->s_data_blksize; data = page_address(page); bh = NULL; @@ -811,8 +811,8 @@ affs_truncate(struct inode *inode) last_blk = 0; ext = 0; if (inode->i_size) { - last_blk = ((u32)inode->i_size - 1) / AFFS_SB->s_data_blksize; - ext = last_blk / AFFS_SB->s_hashsize; + last_blk = ((u32)inode->i_size - 1) / AFFS_SB(sb)->s_data_blksize; + ext = last_blk / AFFS_SB(sb)->s_hashsize; } if (inode->i_size > AFFS_I(inode)->mmu_private) { @@ -857,11 +857,11 @@ affs_truncate(struct inode *inode) i = 0; blk = last_blk; if (inode->i_size) { - i = last_blk % AFFS_SB->s_hashsize + 1; + i = last_blk % AFFS_SB(sb)->s_hashsize + 1; blk++; } else AFFS_HEAD(ext_bh)->first_data = 0; - size = AFFS_SB->s_hashsize; + size = AFFS_SB(sb)->s_hashsize; if (size > blkcnt - blk + i) size = blkcnt - blk + i; for (; i < size; i++, blk++) { @@ -885,7 +885,7 @@ affs_truncate(struct inode *inode) while (ext_key) { ext_bh = affs_bread(sb, ext_key); - size = AFFS_SB->s_hashsize; + size = AFFS_SB(sb)->s_hashsize; if (size > blkcnt - blk) size = blkcnt - blk; for (i = 0; i < size; i++, blk++) diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 33e2241a9944..2a75344cd54c 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -38,6 +38,7 @@ void affs_read_inode(struct inode *inode) { struct super_block *sb = inode->i_sb; + struct affs_sb_info *sbi = AFFS_SB(sb); struct buffer_head *bh; struct affs_head *head; struct affs_tail *tail; @@ -83,35 +84,35 @@ affs_read_inode(struct inode *inode) AFFS_I(inode)->i_lastalloc = 0; AFFS_I(inode)->i_pa_cnt = 0; - if (AFFS_SB->s_flags & SF_SETMODE) - inode->i_mode = AFFS_SB->s_mode; + if (sbi->s_flags & SF_SETMODE) + inode->i_mode = sbi->s_mode; else inode->i_mode = prot_to_mode(prot); id = be16_to_cpu(tail->uid); - if (id == 0 || AFFS_SB->s_flags & SF_SETUID) - inode->i_uid = AFFS_SB->s_uid; - else if (id == 0xFFFF && AFFS_SB->s_flags & SF_MUFS) + if (id == 0 || sbi->s_flags & SF_SETUID) + inode->i_uid = sbi->s_uid; + else if (id == 0xFFFF && sbi->s_flags & SF_MUFS) inode->i_uid = 0; else inode->i_uid = id; id = be16_to_cpu(tail->gid); - if (id == 0 || AFFS_SB->s_flags & SF_SETGID) - inode->i_gid = AFFS_SB->s_gid; - else if (id == 0xFFFF && AFFS_SB->s_flags & SF_MUFS) + if (id == 0 || sbi->s_flags & SF_SETGID) + inode->i_gid = sbi->s_gid; + else if (id == 0xFFFF && sbi->s_flags & SF_MUFS) inode->i_gid = 0; else inode->i_gid = id; switch (be32_to_cpu(tail->stype)) { case ST_ROOT: - inode->i_uid = AFFS_SB->s_uid; - inode->i_gid = AFFS_SB->s_gid; + inode->i_uid = sbi->s_uid; + inode->i_gid = sbi->s_gid; /* fall through */ case ST_USERDIR: if (be32_to_cpu(tail->stype) == ST_USERDIR || - AFFS_SB->s_flags & SF_SETMODE) { + sbi->s_flags & SF_SETMODE) { if (inode->i_mode & S_IRUSR) inode->i_mode |= S_IXUSR; if (inode->i_mode & S_IRGRP) @@ -147,13 +148,13 @@ affs_read_inode(struct inode *inode) AFFS_I(inode)->mmu_private = inode->i_size = size; if (inode->i_size) { AFFS_I(inode)->i_blkcnt = (size - 1) / - AFFS_SB->s_data_blksize + 1; + sbi->s_data_blksize + 1; AFFS_I(inode)->i_extcnt = (AFFS_I(inode)->i_blkcnt - 1) / - AFFS_SB->s_hashsize + 1; + sbi->s_hashsize + 1; } if (tail->link_chain) inode->i_nlink = 2; - inode->i_mapping->a_ops = (AFFS_SB->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; + inode->i_mapping->a_ops = (sbi->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; inode->i_op = &affs_file_inode_operations; inode->i_fop = &affs_file_operations; break; @@ -207,18 +208,18 @@ affs_write_inode(struct inode *inode, int unused) tail->protect = cpu_to_be32(AFFS_I(inode)->i_protect); tail->size = cpu_to_be32(inode->i_size); secs_to_datestamp(inode->i_mtime,&tail->change); - if (!(inode->i_ino == AFFS_SB->s_root_block)) { + if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) { uid = inode->i_uid; gid = inode->i_gid; - if (sb->u.affs_sb.s_flags & SF_MUFS) { + if (AFFS_SB(sb)->s_flags & SF_MUFS) { if (inode->i_uid == 0 || inode->i_uid == 0xFFFF) uid = inode->i_uid ^ ~0; if (inode->i_gid == 0 || inode->i_gid == 0xFFFF) gid = inode->i_gid ^ ~0; } - if (!(sb->u.affs_sb.s_flags & SF_SETUID)) + if (!(AFFS_SB(sb)->s_flags & SF_SETUID)) tail->uid = cpu_to_be16(uid); - if (!(sb->u.affs_sb.s_flags & SF_SETGID)) + if (!(AFFS_SB(sb)->s_flags & SF_SETGID)) tail->gid = cpu_to_be16(gid); } } @@ -240,11 +241,11 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr) if (error) goto out; - if (((attr->ia_valid & ATTR_UID) && (inode->i_sb->u.affs_sb.s_flags & SF_SETUID)) || - ((attr->ia_valid & ATTR_GID) && (inode->i_sb->u.affs_sb.s_flags & SF_SETGID)) || + if (((attr->ia_valid & ATTR_UID) && (AFFS_SB(inode->i_sb)->s_flags & SF_SETUID)) || + ((attr->ia_valid & ATTR_GID) && (AFFS_SB(inode->i_sb)->s_flags & SF_SETGID)) || ((attr->ia_valid & ATTR_MODE) && - (inode->i_sb->u.affs_sb.s_flags & (SF_SETMODE | SF_IMMUTABLE)))) { - if (!(inode->i_sb->u.affs_sb.s_flags & SF_QUIET)) + (AFFS_SB(inode->i_sb)->s_flags & (SF_SETMODE | SF_IMMUTABLE)))) { + if (!(AFFS_SB(inode->i_sb)->s_flags & SF_QUIET)) error = -EPERM; goto out; } diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 495a5481514a..80578e97be18 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -64,7 +64,7 @@ affs_intl_toupper(int ch) static inline toupper_t affs_get_toupper(struct super_block *sb) { - return AFFS_SB->s_flags & SF_INTL ? affs_intl_toupper : affs_toupper; + return AFFS_SB(sb)->s_flags & SF_INTL ? affs_intl_toupper : affs_toupper; } /* @@ -177,7 +177,7 @@ affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len) for (; len > 0; len--) hash = (hash * 13 + toupper(*name++)) & 0x7ff; - return hash % AFFS_SB->s_hashsize; + return hash % AFFS_SB(sb)->s_hashsize; } static struct buffer_head * @@ -244,7 +244,7 @@ affs_lookup(struct inode *dir, struct dentry *dentry) return ERR_PTR(-EACCES); } } - dentry->d_op = AFFS_SB->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations; + dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations; unlock_kernel(); d_add(dentry, inode); return NULL; @@ -289,7 +289,7 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode) inode->i_op = &affs_file_inode_operations; inode->i_fop = &affs_file_operations; - inode->i_mapping->a_ops = (AFFS_SB->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; + inode->i_mapping->a_ops = (AFFS_SB(sb)->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; error = affs_add_entry(dir, inode, dentry, ST_FILE); if (error) { inode->i_nlink = 0; @@ -367,7 +367,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) (int)dentry->d_name.len,dentry->d_name.name,symname); lock_kernel(); - maxlen = AFFS_SB->s_hashsize * sizeof(u32) - 1; + maxlen = AFFS_SB(sb)->s_hashsize * sizeof(u32) - 1; error = -ENOSPC; inode = affs_new_inode(dir); if (!inode) { @@ -390,8 +390,8 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) if (*symname == '/') { while (*symname == '/') symname++; - while (AFFS_SB->s_volume[i]) /* Cannot overflow */ - *p++ = AFFS_SB->s_volume[i++]; + while (AFFS_SB(sb)->s_volume[i]) /* Cannot overflow */ + *p++ = AFFS_SB(sb)->s_volume[i++]; } while (i < maxlen && (c = *symname++)) { if (c == '.' && lc == '/' && *symname == '.' && symname[1] == '/') { diff --git a/fs/affs/super.c b/fs/affs/super.c index feb7cc918841..adfefd10ff90 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -38,21 +38,25 @@ static int affs_remount (struct super_block *sb, int *flags, char *data); static void affs_put_super(struct super_block *sb) { + struct affs_sb_info *sbi = AFFS_SB(sb); + pr_debug("AFFS: put_super()\n"); if (!(sb->s_flags & MS_RDONLY)) { - AFFS_ROOT_TAIL(sb, AFFS_SB->s_root_bh)->bm_flag = be32_to_cpu(1); + AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(1); secs_to_datestamp(CURRENT_TIME, - &AFFS_ROOT_TAIL(sb, AFFS_SB->s_root_bh)->disk_change); - affs_fix_checksum(sb, AFFS_SB->s_root_bh); - mark_buffer_dirty(AFFS_SB->s_root_bh); + &AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change); + affs_fix_checksum(sb, sbi->s_root_bh); + mark_buffer_dirty(sbi->s_root_bh); } - affs_brelse(AFFS_SB->s_bmap_bh); - if (AFFS_SB->s_prefix) - kfree(AFFS_SB->s_prefix); - kfree(AFFS_SB->s_bitmap); - affs_brelse(AFFS_SB->s_root_bh); + affs_brelse(sbi->s_bmap_bh); + if (sbi->s_prefix) + kfree(sbi->s_prefix); + kfree(sbi->s_bitmap); + affs_brelse(sbi->s_root_bh); + kfree(sbi); + sb->u.generic_sbp = NULL; return; } @@ -61,16 +65,17 @@ static void affs_write_super(struct super_block *sb) { int clean = 2; + struct affs_sb_info *sbi = AFFS_SB(sb); if (!(sb->s_flags & MS_RDONLY)) { - // if (AFFS_SB->s_bitmap[i].bm_bh) { - // if (buffer_dirty(AFFS_SB->s_bitmap[i].bm_bh)) { + // if (sbi->s_bitmap[i].bm_bh) { + // if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) { // clean = 0; - AFFS_ROOT_TAIL(sb, AFFS_SB->s_root_bh)->bm_flag = be32_to_cpu(clean); + AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(clean); secs_to_datestamp(CURRENT_TIME, - &AFFS_ROOT_TAIL(sb, AFFS_SB->s_root_bh)->disk_change); - affs_fix_checksum(sb, AFFS_SB->s_root_bh); - mark_buffer_dirty(AFFS_SB->s_root_bh); + &AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change); + affs_fix_checksum(sb, sbi->s_root_bh); + mark_buffer_dirty(sbi->s_root_bh); sb->s_dirt = !clean; /* redo until bitmap synced */ } else sb->s_dirt = 0; @@ -267,6 +272,7 @@ out_inv_arg: static int affs_fill_super(struct super_block *sb, void *data, int silent) { + struct affs_sb_info *sbi; struct buffer_head *root_bh = NULL; struct buffer_head *boot_bh; struct inode *root_inode = NULL; @@ -285,22 +291,27 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) sb->s_magic = AFFS_SUPER_MAGIC; sb->s_op = &affs_sops; - memset(AFFS_SB, 0, sizeof(struct affs_sb_info)); - init_MUTEX(&AFFS_SB->s_bmlock); + + sbi = kmalloc(sizeof(struct affs_sb_info), GFP_KERNEL); + if (!sbi) + return -ENOMEM; + sb->u.generic_sbp = sbi; + memset(sbi, 0, sizeof(struct affs_sb_info)); + init_MUTEX(&sbi->s_bmlock); if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, - &blocksize,&AFFS_SB->s_prefix, - AFFS_SB->s_volume, &mount_flags)) { + &blocksize,&sbi->s_prefix, + sbi->s_volume, &mount_flags)) { printk(KERN_ERR "AFFS: Error parsing options\n"); return -EINVAL; } /* N.B. after this point s_prefix must be released */ - AFFS_SB->s_flags = mount_flags; - AFFS_SB->s_mode = i; - AFFS_SB->s_uid = uid; - AFFS_SB->s_gid = gid; - AFFS_SB->s_reserved= reserved; + sbi->s_flags = mount_flags; + sbi->s_mode = i; + sbi->s_uid = uid; + sbi->s_gid = gid; + sbi->s_reserved= reserved; /* Get the size of the device in 512-byte blocks. * If we later see that the partition uses bigger @@ -320,12 +331,12 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) size = size / (blocksize / 512); } for (blocksize = i, key = 0; blocksize <= j; blocksize <<= 1, size >>= 1) { - AFFS_SB->s_root_block = root_block; + sbi->s_root_block = root_block; if (root_block < 0) - AFFS_SB->s_root_block = (reserved + size - 1) / 2; + sbi->s_root_block = (reserved + size - 1) / 2; pr_debug("AFFS: setting blocksize to %d\n", blocksize); affs_set_blocksize(sb, blocksize); - AFFS_SB->s_partition_size = size; + sbi->s_partition_size = size; /* The root block location that was calculated above is not * correct if the partition size is an odd number of 512- @@ -341,16 +352,16 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) pr_debug("AFFS: Dev %s, trying root=%u, bs=%d, " "size=%d, reserved=%d\n", sb->s_id, - AFFS_SB->s_root_block + num_bm, + sbi->s_root_block + num_bm, blocksize, size, reserved); - root_bh = affs_bread(sb, AFFS_SB->s_root_block + num_bm); + root_bh = affs_bread(sb, sbi->s_root_block + num_bm); if (!root_bh) continue; if (!affs_checksum_block(sb, root_bh) && be32_to_cpu(AFFS_ROOT_HEAD(root_bh)->ptype) == T_SHORT && be32_to_cpu(AFFS_ROOT_TAIL(sb, root_bh)->stype) == ST_ROOT) { - AFFS_SB->s_hashsize = blocksize / 4 - 56; - AFFS_SB->s_root_block += num_bm; + sbi->s_hashsize = blocksize / 4 - 56; + sbi->s_root_block += num_bm; key = 1; goto got_root; } @@ -365,7 +376,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) /* N.B. after this point bh must be released */ got_root: - root_block = AFFS_SB->s_root_block; + root_block = sbi->s_root_block; /* Find out which kind of FS we have */ boot_bh = sb_bread(sb, 0); @@ -385,36 +396,36 @@ got_root: printk(KERN_NOTICE "AFFS: Dircache FS - mounting %s read only\n", sb->s_id); sb->s_flags |= MS_RDONLY; - AFFS_SB->s_flags |= SF_READONLY; + sbi->s_flags |= SF_READONLY; } switch (chksum) { case MUFS_FS: case MUFS_INTLFFS: case MUFS_DCFFS: - AFFS_SB->s_flags |= SF_MUFS; + sbi->s_flags |= SF_MUFS; /* fall thru */ case FS_INTLFFS: case FS_DCFFS: - AFFS_SB->s_flags |= SF_INTL; + sbi->s_flags |= SF_INTL; break; case MUFS_FFS: - AFFS_SB->s_flags |= SF_MUFS; + sbi->s_flags |= SF_MUFS; break; case FS_FFS: break; case MUFS_OFS: - AFFS_SB->s_flags |= SF_MUFS; + sbi->s_flags |= SF_MUFS; /* fall thru */ case FS_OFS: - AFFS_SB->s_flags |= SF_OFS; + sbi->s_flags |= SF_OFS; sb->s_flags |= MS_NOEXEC; break; case MUFS_DCOFS: case MUFS_INTLOFS: - AFFS_SB->s_flags |= SF_MUFS; + sbi->s_flags |= SF_MUFS; case FS_DCOFS: case FS_INTLOFS: - AFFS_SB->s_flags |= SF_INTL | SF_OFS; + sbi->s_flags |= SF_INTL | SF_OFS; sb->s_flags |= MS_NOEXEC; break; default: @@ -433,12 +444,12 @@ got_root: sb->s_flags |= MS_NODEV | MS_NOSUID; - AFFS_SB->s_data_blksize = sb->s_blocksize; - if (AFFS_SB->s_flags & SF_OFS) - AFFS_SB->s_data_blksize -= 24; + sbi->s_data_blksize = sb->s_blocksize; + if (sbi->s_flags & SF_OFS) + sbi->s_data_blksize -= 24; /* Keep super block in cache */ - AFFS_SB->s_root_bh = root_bh; + sbi->s_root_bh = root_bh; /* N.B. after this point s_root_bh must be released */ if (affs_init_bitmap(sb)) @@ -463,17 +474,20 @@ got_root: out_error: if (root_inode) iput(root_inode); - if (AFFS_SB->s_bitmap) - kfree(AFFS_SB->s_bitmap); + if (sbi->s_bitmap) + kfree(sbi->s_bitmap); affs_brelse(root_bh); - if (AFFS_SB->s_prefix) - kfree(AFFS_SB->s_prefix); + if (sbi->s_prefix) + kfree(sbi->s_prefix); + kfree(sbi); + sb->u.generic_sbp = NULL; return -EINVAL; } static int affs_remount(struct super_block *sb, int *flags, char *data) { + struct affs_sb_info *sbi = AFFS_SB(sb); int blocksize; uid_t uid; gid_t gid; @@ -481,17 +495,17 @@ affs_remount(struct super_block *sb, int *flags, char *data) int reserved; int root_block; unsigned long mount_flags; - unsigned long read_only = AFFS_SB->s_flags & SF_READONLY; + unsigned long read_only = sbi->s_flags & SF_READONLY; pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); if (!parse_options(data,&uid,&gid,&mode,&reserved,&root_block, - &blocksize,&AFFS_SB->s_prefix,AFFS_SB->s_volume,&mount_flags)) + &blocksize,&sbi->s_prefix,sbi->s_volume,&mount_flags)) return -EINVAL; - AFFS_SB->s_flags = mount_flags | read_only; - AFFS_SB->s_mode = mode; - AFFS_SB->s_uid = uid; - AFFS_SB->s_gid = gid; + sbi->s_flags = mount_flags | read_only; + sbi->s_mode = mode; + sbi->s_uid = uid; + sbi->s_gid = gid; if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) return 0; @@ -500,7 +514,7 @@ affs_remount(struct super_block *sb, int *flags, char *data) while (sb->s_dirt) affs_write_super(sb); sb->s_flags |= MS_RDONLY; - } else if (!(AFFS_SB->s_flags & SF_READONLY)) { + } else if (!(sbi->s_flags & SF_READONLY)) { sb->s_flags &= ~MS_RDONLY; } else { affs_warning(sb,"remount","Cannot remount fs read/write because of errors"); @@ -514,13 +528,13 @@ affs_statfs(struct super_block *sb, struct statfs *buf) { int free; - pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB->s_partition_size, - AFFS_SB->s_reserved); + pr_debug("AFFS: statfs() partsize=%d, reserved=%d\n",AFFS_SB(sb)->s_partition_size, + AFFS_SB(sb)->s_reserved); free = affs_count_free_blocks(sb); buf->f_type = AFFS_SUPER_MAGIC; buf->f_bsize = sb->s_blocksize; - buf->f_blocks = AFFS_SB->s_partition_size - AFFS_SB->s_reserved; + buf->f_blocks = AFFS_SB(sb)->s_partition_size - AFFS_SB(sb)->s_reserved; buf->f_bfree = free; buf->f_bavail = free; return 0; diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c index f8eedba6fdd3..b4c2e20e07e1 100644 --- a/fs/affs/symlink.c +++ b/fs/affs/symlink.c @@ -40,7 +40,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page) j = 0; lf = (struct slink_front *)bh->b_data; lc = 0; - pf = inode->i_sb->u.affs_sb.s_prefix ? inode->i_sb->u.affs_sb.s_prefix : "/"; + pf = AFFS_SB(inode->i_sb)->s_prefix ? AFFS_SB(inode->i_sb)->s_prefix : "/"; if (strchr(lf->symname,':')) { /* Handle assign or volume name */ while (i < 1023 && (c = pf[i])) diff --git a/include/linux/affs_fs.h b/include/linux/affs_fs.h index 7859a5e1883c..47ed05c8b744 100644 --- a/include/linux/affs_fs.h +++ b/include/linux/affs_fs.h @@ -7,6 +7,7 @@ #include #include +#include #define AFFS_SUPER_MAGIC 0xadff diff --git a/include/linux/affs_fs_sb.h b/include/linux/affs_fs_sb.h index 5a0485e97fd9..1f39cd806800 100644 --- a/include/linux/affs_fs_sb.h +++ b/include/linux/affs_fs_sb.h @@ -50,6 +50,9 @@ struct affs_sb_info { #define SF_READONLY 0x1000 /* Don't allow to remount rw */ /* short cut to get to the affs specific sb data */ -#define AFFS_SB (&sb->u.affs_sb) +static inline struct affs_sb_info *AFFS_SB(struct super_block *sb) +{ + return sb->u.generic_sbp; +} #endif diff --git a/include/linux/amigaffs.h b/include/linux/amigaffs.h index b4b1d430c306..342ab37e0c2e 100644 --- a/include/linux/amigaffs.h +++ b/include/linux/amigaffs.h @@ -18,7 +18,7 @@ #define GET_END_PTR(st,p,sz) ((st *)((char *)(p)+((sz)-sizeof(st)))) #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey]) -#define AFFS_BLOCK(sb, bh, blk) (AFFS_HEAD(bh)->table[(sb)->u.affs_sb.s_hashsize-1-(blk)]) +#define AFFS_BLOCK(sb, bh, blk) (AFFS_HEAD(bh)->table[AFFS_SB(sb)->s_hashsize-1-(blk)]) static inline void affs_set_blocksize(struct super_block *sb, int size) @@ -29,7 +29,7 @@ static inline struct buffer_head * affs_bread(struct super_block *sb, int block) { pr_debug(KERN_DEBUG "affs_bread: %d\n", block); - if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) + if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) return sb_bread(sb, block); return NULL; } @@ -37,7 +37,7 @@ static inline struct buffer_head * affs_getblk(struct super_block *sb, int block) { pr_debug(KERN_DEBUG "affs_getblk: %d\n", block); - if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) + if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) return sb_getblk(sb, block); return NULL; } @@ -46,7 +46,7 @@ affs_getzeroblk(struct super_block *sb, int block) { struct buffer_head *bh; pr_debug(KERN_DEBUG "affs_getzeroblk: %d\n", block); - if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) { + if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { bh = sb_getblk(sb, block); lock_buffer(bh); memset(bh->b_data, 0 , sb->s_blocksize); @@ -61,7 +61,7 @@ affs_getemptyblk(struct super_block *sb, int block) { struct buffer_head *bh; pr_debug(KERN_DEBUG "affs_getemptyblk: %d\n", block); - if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) { + if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { bh = sb_getblk(sb, block); wait_on_buffer(bh); mark_buffer_uptodate(bh, 1); diff --git a/include/linux/fs.h b/include/linux/fs.h index a1ae91bafcfc..85ae3dcb6496 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -648,7 +648,6 @@ struct quota_mount_options #include #include #include -#include #include #include #include @@ -693,7 +692,6 @@ struct super_block { struct hpfs_sb_info hpfs_sb; struct ntfs_sb_info ntfs_sb; struct sysv_sb_info sysv_sb; - struct affs_sb_info affs_sb; struct ufs_sb_info ufs_sb; struct romfs_sb_info romfs_sb; struct adfs_sb_info adfs_sb; -- cgit v1.2.3