Skip to content

Commit 43c7322

Browse files
committed
ext4: replace BUG_ON with WARN_ON in mb_find_extent()
The last BUG_ON in mb_find_extent() is apparently triggering in some rare cases. Most of the time it indicates a bug in the buddy bitmap algorithms, but there are some weird cases where it can trigger when buddy bitmap is still in memory, but the block bitmap has to be read from disk, and there is disk or memory corruption such that the block bitmap and the buddy bitmap are out of sync. Google-Bug-Id: #33702157 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 01daf94 commit 43c7322

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎fs/ext4/mballoc.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,17 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
15561556
ex->fe_len += 1 << order;
15571557
}
15581558

1559-
BUG_ON(ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3)));
1559+
if (ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3))) {
1560+
/* Should never happen! (but apparently sometimes does?!?) */
1561+
WARN_ON(1);
1562+
ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "
1563+
"block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
1564+
block, order, needed, ex->fe_group, ex->fe_start,
1565+
ex->fe_len, ex->fe_logical);
1566+
ex->fe_len = 0;
1567+
ex->fe_start = 0;
1568+
ex->fe_group = 0;
1569+
}
15601570
return ex->fe_len;
15611571
}
15621572

0 commit comments

Comments
 (0)