diff options
| author | Geert Uytterhoeven <geert@linux-m68k.org> | 2004-06-19 20:38:35 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-06-19 20:38:35 -0700 |
| commit | f51dc7a2a47aff78a05d65b6affccebd35fb68de (patch) | |
| tree | b129f1c1422b26bf497cd9e5923db3c050e894d1 /fs/affs/bitmap.c | |
| parent | 74325fde44f58b6de42be9eed0ac31ba8c98dd8d (diff) | |
[PATCH] affs remount fixes
AFFS: Fix oops on write after remount (from Roman Zippel):
- Allocate/free bitmap as necessary
- Remove last uses of SF_READONLY
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/affs/bitmap.c')
| -rw-r--r-- | fs/affs/bitmap.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index 095ef77a407e..93d32d18e97f 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c @@ -272,8 +272,7 @@ err_full: return 0; } -int -affs_init_bitmap(struct super_block *sb) +int affs_init_bitmap(struct super_block *sb, int *flags) { struct affs_bm_info *bm; struct buffer_head *bmap_bh = NULL, *bh = NULL; @@ -282,13 +281,13 @@ affs_init_bitmap(struct super_block *sb) int i, res = 0; struct affs_sb_info *sbi = AFFS_SB(sb); - if (sb->s_flags & MS_RDONLY) + if (*flags & MS_RDONLY) return 0; 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; + *flags |= MS_RDONLY; return 0; } @@ -301,7 +300,7 @@ affs_init_bitmap(struct super_block *sb) bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL); if (!sbi->s_bitmap) { printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); - return 1; + return -ENOMEM; } memset(sbi->s_bitmap, 0, size); @@ -316,13 +315,13 @@ affs_init_bitmap(struct super_block *sb) bh = affs_bread(sb, bm->bm_key); if (!bh) { printk(KERN_ERR "AFFS: Cannot read bitmap\n"); - res = 1; + res = -EIO; goto out; } if (affs_checksum_block(sb, bh)) { printk(KERN_WARNING "AFFS: Bitmap %u invalid - mounting %s read only.\n", bm->bm_key, sb->s_id); - sb->s_flags |= MS_RDONLY; + *flags |= MS_RDONLY; goto out; } pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); @@ -338,7 +337,7 @@ affs_init_bitmap(struct super_block *sb) bmap_bh = affs_bread(sb, be32_to_cpu(bmap_blk[blk])); if (!bmap_bh) { printk(KERN_ERR "AFFS: Cannot read bitmap extension\n"); - res = 1; + res = -EIO; goto out; } bmap_blk = (u32 *)bmap_bh->b_data; @@ -383,3 +382,17 @@ out: affs_brelse(bmap_bh); return res; } + +void affs_free_bitmap(struct super_block *sb) +{ + struct affs_sb_info *sbi = AFFS_SB(sb); + + if (!sbi->s_bitmap) + return; + + affs_brelse(sbi->s_bmap_bh); + sbi->s_bmap_bh = NULL; + sbi->s_last_bmap = ~0; + kfree(sbi->s_bitmap); + sbi->s_bitmap = NULL; +} |
