[PATCH 3/3] btrfs: Do super block verification before writing it to disk

2018-04-19 Thread Qu Wenruo
There are already 2 reports about strangely corrupted super blocks, where csum still matches but extra garbage gets slipped into super block. The corruption would looks like: -- superblock: bytenr=65536, device=/dev/sdc1 - csum_type

Re: [PATCH 3/3] btrfs: Do super block verification before writing it to disk

2018-04-19 Thread David Sterba
Looks good, some minor comments below. I'm wondering how to test that. We'd have to inject either the corruption or to provide a way to forcibly fail the test. For the latter a debugfs should do, I'll send something for comments. On Thu, Apr 19, 2018 at 05:38:16PM +0800, Qu Wenruo wrote: > @@ -356

Re: [PATCH 3/3] btrfs: Do super block verification before writing it to disk

2018-04-19 Thread Qu Wenruo
On 2018年04月19日 18:16, David Sterba wrote: > Looks good, some minor comments below. I'm wondering how to test that. Currently I'm using the most stupid way to test it, insert code randomly modifies super blocks. > We'd have to inject either the corruption or to provide a way to > forcibly fail t

Re: [PATCH 3/3] btrfs: Do super block verification before writing it to disk

2018-04-20 Thread Anand Jain
@@ -3563,6 +3565,12 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors) sb = fs_info->super_for_commit; dev_item = &sb->dev_item; + if (btrfs_check_super_valid(fs_info, sb, -1)) { + btrfs_err(fs_info, + "superblock corruptio