Skip to contentSkip to conversation

Ext4: remove a useless check for the function ext4_data_block_valid

PATCH In review Wang Shilong 2 participants 4 messages Jan 26, 2013 – Jan 27, 2013 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Ext4: remove a useless check for the function ext4_data_block_valid

From: Wang Shilong <[email protected]>

Because it is no doubt 'start_blk + count < start_blk' always comes to false. It is useless to have this check,remove it.

---
 fs/ext4/block_validity.c | 1 -
 1 file changed, 1 deletion(-)
fs/ext4/block_validity.c +0 -1
index 3f11656..5ffce82 100644
@@ -226,7 +226,6 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
 	struct rb_node *n = sbi->system_blks.rb_node;
 
 	if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
-	    (start_blk + count < start_blk) ||
 	    (start_blk + count > ext4_blocks_count(sbi->s_es))) {
 		sbi->s_es->s_last_error_block = cpu_to_le64(start_blk);
 		return 0;

-- 1.7.11.7

maintainer
#1 lore raw
Quoted 4 lines · Wang Shilong

From: Wang Shilong <[email protected]>

Because it is no doubt 'start_blk + count < start_blk' always comes to false. It is useless to have this check,remove it.

Actually, it can be true --- if start_blk + count (which are both unsigned integers) overflows....

- Ted

#2 lore raw
Quoted 7 lines · Wang Shilong
Quoted 4 lines

From: Wang Shilong <[email protected]>

Because it is no doubt 'start_blk + count < start_blk' always comes to false. It is useless to have this check,remove it.

Actually, it can be true --- if start_blk + count (which are both unsigned integers) overflows....

Yeah,you are right....
I am sorry,I miss the overflow condition...

Quoted 2 lines

- Ted

maintainer
#3 lore raw
Quoted 4 lines · Wang Shilong
Quoted 2 lines

Actually, it can be true --- if start_blk + count (which are both unsigned integers) overflows....

Yeah,you are right....
I am sorry,I miss the overflow condition...

We added it because we saw a crash that was a caused by an overflow, if memory serves correctly. Or maybe it was a mysterious data or file system corruption that was incredibly painful to find.

Fun trivia fact: the European Space Agency had the Ariane 5 rocket explode on its maiden flight due to a integer overflow bug.

- Ted