Skip to contentSkip to conversation

ext4: Use the correct block number when reading the super block.

PATCH New Aneesh Kumar K.V 1 participant 1 message Dec 31, 2007 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Use the correct block number when reading the super block.

If the block device hard sector size is larger than EXT4_MIN_BLOCK_SIZE we end up with wrong block number when reading super block.

---
 fs/ext4/super.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/super.c +2 -2
index 1ca0f54..832e1ad 100644
@@ -1629,8 +1629,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
 	 * block sizes.  We need to calculate the offset from buffer start.
 	 */
 	if (blocksize != EXT4_MIN_BLOCK_SIZE) {
-		logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
-		offset = do_div(logical_sb_block, blocksize);
+		logical_sb_block = (sb_block * EXT4_MIN_BLOCK_SIZE) / blocksize;
+		offset = do_div((sb_block * EXT4_MIN_BLOCK_SIZE), blocksize);
 	} else {
 		logical_sb_block = sb_block;
 	}
Signature · 1 line
1.5.4.rc2-dirty