Commit ce40733c authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Theodore Ts'o

ext4: Check for return value from sb_set_blocksize

sb_set_blocksize validates whether the specfied block size can be used by
the file system. Make sure we fail mounting the file system if the
blocksize specfied cannot be used.
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: default avatarMingming Cao <cmm@us.ibm.com>
parent cb45bbe4
...@@ -1812,7 +1812,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1812,7 +1812,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
unsigned long def_mount_opts; unsigned long def_mount_opts;
struct inode *root; struct inode *root;
int blocksize; int blocksize;
int hblock;
int db_count; int db_count;
int i; int i;
int needs_recovery; int needs_recovery;
...@@ -1969,20 +1968,16 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1969,20 +1968,16 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
goto failed_mount; goto failed_mount;
} }
hblock = bdev_hardsect_size(sb->s_bdev);
if (sb->s_blocksize != blocksize) { if (sb->s_blocksize != blocksize) {
/*
* Make sure the blocksize for the filesystem is larger /* Validate the filesystem blocksize */
* than the hardware sectorsize for the machine. if (!sb_set_blocksize(sb, blocksize)) {
*/ printk(KERN_ERR "EXT4-fs: bad block size %d.\n",
if (blocksize < hblock) { blocksize);
printk(KERN_ERR "EXT4-fs: blocksize %d too small for "
"device blocksize %d.\n", blocksize, hblock);
goto failed_mount; goto failed_mount;
} }
brelse (bh); brelse (bh);
sb_set_blocksize(sb, blocksize);
logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
offset = do_div(logical_sb_block, blocksize); offset = do_div(logical_sb_block, blocksize);
bh = sb_bread(sb, logical_sb_block); bh = sb_bread(sb, logical_sb_block);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment