HACK: ext4: make bitmap corruption not fatal
There can be occasional reasons for bitmap problems, which are
detected by ext4_mb_check_ondisk_bitmap() and cause the
filesystem to be remounted read-only due to ext4_error():
EXT4-fs error (device /dev/dm-6-8): ext4_mb_generate_buddy:755:
group 294, block 0: block bitmap and bg descriptor inconsistent:
20180 vs 20181 free clusters
Aborting journal on device dm-6-8.
EXT4-fs (dm-6): Remounting filesystem read-only
This might be caused by some ext4 internal bugs, which are addressed
separately. This patch makes ext4 more robust by the following changes:
- ext4_read_block_bitmap() printed error, so do not call ext4_error() again
- mark all bits in bitmap used so that it will not be used for allocation
- mark block group corrupt, use ext4_warning() instead of ext4_error()
Tested by following script:
TEST_DEV="/dev/sdb"
TEST_MNT="/mnt/ext4"
mkdir -p $TEST_MNT
mkfs.ext4 -F $TEST_DEV
mount -t ext4 $TEST_DEV $TEST_MNT
dd if=/dev/zero of=$TEST_MNT/largefile oflag=direct bs=
10485760 count=200
umount $TEST_MNT
dd if=/dev/zero of=$TEST_DEV oflag=direct bs=4096 seek=641 count=10
mount -t ext4 $TEST_DEV $TEST_MNT
rm -f $TEST_MNT/largefile
dd if=/dev/zero of=$TEST_MNT/largefile oflag=direct bs=
10485760 count=200 &&
echo "FILESYSTEM still usable after bitmaps corrupts happen"
umount $TEST_MNT
e2fsck $TEST_DEV -y
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1026
Reviewed-on: http://review.whamcloud.com/16679
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>