OSDN Git Service

HACK: ext4: make bitmap corruption not fatal
authorWang Shilong <wshilong@ddn.com>
Sat, 11 Jul 2015 03:49:55 +0000 (11:49 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 19 Apr 2017 15:35:25 +0000 (23:35 +0800)
commit59c5aecde5960f62d4126d041ab1ab3c876e3012
tree24c16614a7b19c51d02b38ae9cdd428b3adaa886
parentd24129103a3695c37eb18a2d5b1cd2d1dac131d0
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>
fs/ext4/balloc.c
fs/ext4/ext4.h
fs/ext4/ialloc.c
fs/ext4/mballoc.c
fs/ext4/super.c