minix zmap block counts calculation fix
authorQi Yong <qiyong@fc-cn.com>
Fri, 8 Aug 2014 21:20:29 +0000 (14:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Aug 2014 22:57:20 +0000 (15:57 -0700)
The original minix zmap blocks calculation was correct, in the formula of:

sbi->s_nzones - sbi->s_firstdatazone + 1

It is

sp->s_zones - (sp->s_firstdatazone - 1)

in the minix3 source code.

But a later commit 016e8d44bc06 ("fs/minix: Verify bitmap block counts
before mounting") has changed it unfortunately as:

  sbi->s_nzones - (sbi->s_firstdatazone + 1)

This would show free blocks one block less than the real when the total
data blocks are in "full zmap blocks plus one".

This patch corrects that zmap blocks calculation and tidy a printk
message while at it.

Signed-off-by: Qi Yong <qiyong@fc-cn.com>
Cc: Josh Boyer <jwboyer@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/minix/bitmap.c
fs/minix/inode.c

index 4bc50dac8e979faf4f299d1538d5462329191fa1..742942a983be8c73cf9f3ea01639ccfe86367e18 100644 (file)
@@ -96,7 +96,7 @@ int minix_new_block(struct inode * inode)
 unsigned long minix_count_free_blocks(struct super_block *sb)
 {
        struct minix_sb_info *sbi = minix_sb(sb);
-       u32 bits = sbi->s_nzones - (sbi->s_firstdatazone + 1);
+       u32 bits = sbi->s_nzones - sbi->s_firstdatazone + 1;
 
        return (count_free(sbi->s_zmap, sb->s_blocksize, bits)
                << sbi->s_log_zone_size);
index f007a3355570b38de89b57343407ccafad6cbe21..3f57af196a7de36343be9249d2e883a9b162310b 100644 (file)
@@ -267,12 +267,12 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
        block = minix_blocks_needed(sbi->s_ninodes, s->s_blocksize);
        if (sbi->s_imap_blocks < block) {
                printk("MINIX-fs: file system does not have enough "
-                               "imap blocks allocated.  Refusing to mount\n");
+                               "imap blocks allocated.  Refusing to mount.\n");
                goto out_no_bitmap;
        }
 
        block = minix_blocks_needed(
-                       (sbi->s_nzones - (sbi->s_firstdatazone + 1)),
+                       (sbi->s_nzones - sbi->s_firstdatazone + 1),
                        s->s_blocksize);
        if (sbi->s_zmap_blocks < block) {
                printk("MINIX-fs: file system does not have enough "