Skip to content

Commit

Permalink
minix zmap block counts calculation fix
Browse files Browse the repository at this point in the history
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 016e8d4 ("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 <[email protected]>
Cc: Josh Boyer <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Qi Yong authored and torvalds committed Aug 8, 2014
1 parent 9f7d7a1 commit 6d6747f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/minix/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit 6d6747f

Please sign in to comment.