Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

minix zmap block counts calculation fix

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>

authored by

Qi Yong and committed by
Linus Torvalds
6d6747f8 9f7d7a1d

+3 -3
+1 -1
fs/minix/bitmap.c
··· 96 96 unsigned long minix_count_free_blocks(struct super_block *sb) 97 97 { 98 98 struct minix_sb_info *sbi = minix_sb(sb); 99 - u32 bits = sbi->s_nzones - (sbi->s_firstdatazone + 1); 99 + u32 bits = sbi->s_nzones - sbi->s_firstdatazone + 1; 100 100 101 101 return (count_free(sbi->s_zmap, sb->s_blocksize, bits) 102 102 << sbi->s_log_zone_size);
+2 -2
fs/minix/inode.c
··· 267 267 block = minix_blocks_needed(sbi->s_ninodes, s->s_blocksize); 268 268 if (sbi->s_imap_blocks < block) { 269 269 printk("MINIX-fs: file system does not have enough " 270 - "imap blocks allocated. Refusing to mount\n"); 270 + "imap blocks allocated. Refusing to mount.\n"); 271 271 goto out_no_bitmap; 272 272 } 273 273 274 274 block = minix_blocks_needed( 275 - (sbi->s_nzones - (sbi->s_firstdatazone + 1)), 275 + (sbi->s_nzones - sbi->s_firstdatazone + 1), 276 276 s->s_blocksize); 277 277 if (sbi->s_zmap_blocks < block) { 278 278 printk("MINIX-fs: file system does not have enough "