diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-25 09:44:53 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-25 10:29:21 -0400 |
commit | 89c0fd014d34d409a7b196667c2b9a4813b6c968 (patch) | |
tree | 9fad0ab3ce77b7537ed7d8db45c40e746e26692f /fs/nilfs2 | |
parent | 6cda9fa2575ec0869fe77b0bdf295c0e51868cab (diff) |
nilfs2: reject filesystem with unsupported block size
This inserts sanity check that refuses to mount a filesystem with
unsupported block size.
Previously, kernel code of nilfs was looking only limitation of
devices though mkfs.nilfs2 limits the range of block sizes; there was
no check that prevents rec_len overflow with larger block sizes.
With this change, block sizes larger than 64KB or smaller than 1KB
will get rejected explicitly by kernel.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index da67b560f3c3..37de1f062d81 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -671,7 +671,7 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | |||
671 | goto out; | 671 | goto out; |
672 | } | 672 | } |
673 | 673 | ||
674 | blocksize = sb_min_blocksize(sb, BLOCK_SIZE); | 674 | blocksize = sb_min_blocksize(sb, NILFS_MIN_BLOCK_SIZE); |
675 | if (!blocksize) { | 675 | if (!blocksize) { |
676 | printk(KERN_ERR "NILFS: unable to set blocksize\n"); | 676 | printk(KERN_ERR "NILFS: unable to set blocksize\n"); |
677 | err = -EINVAL; | 677 | err = -EINVAL; |
@@ -690,6 +690,13 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | |||
690 | goto failed_sbh; | 690 | goto failed_sbh; |
691 | 691 | ||
692 | blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size); | 692 | blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size); |
693 | if (blocksize < NILFS_MIN_BLOCK_SIZE || | ||
694 | blocksize > NILFS_MAX_BLOCK_SIZE) { | ||
695 | printk(KERN_ERR "NILFS: couldn't mount because of unsupported " | ||
696 | "filesystem blocksize %d\n", blocksize); | ||
697 | err = -EINVAL; | ||
698 | goto failed_sbh; | ||
699 | } | ||
693 | if (sb->s_blocksize != blocksize) { | 700 | if (sb->s_blocksize != blocksize) { |
694 | int hw_blocksize = bdev_logical_block_size(sb->s_bdev); | 701 | int hw_blocksize = bdev_logical_block_size(sb->s_bdev); |
695 | 702 | ||