Commit 83c68bb
btrfs: initialize fs_info::csum_size earlier in open_ctree
User reported that btrfs-progs misc-tests/028-superblock-recover fails:
[TEST/misc] 028-superblock-recover
unexpected success: mounted fs with corrupted superblock
test failed for case 028-superblock-recover
The test case expects that a broken image with bad superblock will be
rejected to be mounted. However, the test image just passed csum check
of superblock and was successfully mounted.
Commit 55fc29b ("btrfs: use cached value of fs_info::csum_size
everywhere") replaces all calls to btrfs_super_csum_size by
fs_info::csum_size. The calls include the place where fs_info->csum_size
is not initialized. So btrfs_check_super_csum() passes because memcmp()
with len 0 always returns 0.
Fix it by caching csum size in btrfs_fs_info::csum_size once we know the
csum type in superblock is valid in open_ctree().
Link: kdave/btrfs-progs#250
Fixes: 55fc29b ("btrfs: use cached value of fs_info::csum_size everywhere")
Signed-off-by: Su Yue <l@damenly.su>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent 9ad6d91 commit 83c68bb
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3044 | 3044 | | |
3045 | 3045 | | |
3046 | 3046 | | |
| 3047 | + | |
| 3048 | + | |
3047 | 3049 | | |
3048 | 3050 | | |
3049 | 3051 | | |
| |||
3161 | 3163 | | |
3162 | 3164 | | |
3163 | 3165 | | |
3164 | | - | |
3165 | 3166 | | |
3166 | 3167 | | |
3167 | 3168 | | |
| |||
0 commit comments