Skip to contentSkip to conversation

ext2fs_block_alloc_stats2: fix size comparison for 64-bit compatibility.

PATCH In review Nick Dokos 2 participants 2 messages Apr 8, 2009 – Apr 15, 2009

lore
Share & tools
lore

Nick Dokos

author
#0 lore raw

PATCH 1/5 ext2fs_block_alloc_stats2: fix size comparison for 64-bit compatibility.

The block number comparison in ext2fs_block_alloc_stats2() is invalid for 64-bit filesystems: it compares the block number to the low 32-bits of the blocks_count in the superblock. That caused the journal file for a 32TiB filesystem to be malformed and the resulting filesystem could not be mounted.

The function now uses ext2fs_blocks_count() [from blknum.c] to calculate the number of blocks.

With this change, the journal looks sane and the filesystem could be mounted.

---
 lib/ext2fs/alloc_stats.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/ext2fs/alloc_stats.c +1 -1
index 7895aee..f0c5a64 100644
@@ -65,7 +65,7 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
 	int	group = ext2fs_group_of_blk2(fs, blk);
 
 #ifndef OMIT_COM_ERR
-	if (blk >= fs->super->s_blocks_count) {
+	if (blk >= ext2fs_blocks_count(fs->super)) {
 		com_err("ext2fs_block_alloc_stats2", 0,
 			"Illegal block number: %lu", blk);
 		return;
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 6 lines · Nick Dokos

The block number comparison in ext2fs_block_alloc_stats2() is invalid for 64-bit filesystems: it compares the block number to the low 32-bits of the blocks_count in the superblock. That caused the journal file for a 32TiB filesystem to be malformed and the resulting filesystem could not be mounted.

Quoted 7 lines

The function now uses ext2fs_blocks_count() [from blknum.c] to calculate the number of blocks.

With this change, the journal looks sane and the filesystem could be mounted.

Quoted 20 lines
---
 lib/ext2fs/alloc_stats.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/ext2fs/alloc_stats.c +1 -1
index 7895aee..f0c5a64 100644
@@ -65,7 +65,7 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
 	int	group = ext2fs_group_of_blk2(fs, blk);
 
 #ifndef OMIT_COM_ERR
-	if (blk >= fs->super->s_blocks_count) {
+	if (blk >= ext2fs_blocks_count(fs->super)) {
 		com_err("ext2fs_block_alloc_stats2", 0,
 			"Illegal block number: %lu", blk);
 		return;
Signature · 1 line
1.6.0.6