Skip to content

Commit

Permalink
minixfs: fix block limit check
Browse files Browse the repository at this point in the history
On minix2 and minix3 usually max_size is 7fffffff and the check in
question prohibits creation of last block spanning right before 7fffffff,
due to downward rounding during the division.  Fix it by using
multiplication instead.

[[email protected]: fix up code layout, use local `sb']
Signed-off-by: Vladimir Serbinenko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
phcoder authored and torvalds committed Jul 31, 2012
1 parent 8dccaf0 commit 6ed6a72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/minix/itree_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
if (block < 0) {
printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n",
block, bdevname(sb->s_bdev, b));
} else if (block >= (minix_sb(inode->i_sb)->s_max_size/sb->s_blocksize)) {
} else if ((u64)block * (u64)sb->s_blocksize >=
minix_sb(sb)->s_max_size) {
if (printk_ratelimit())
printk("MINIX-fs: block_to_path: "
"block %ld too big on dev %s\n",
Expand Down

0 comments on commit 6ed6a72

Please sign in to comment.