diff options
author | David Sterba <dsterba@suse.cz> | 2013-03-06 09:57:46 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-05-07 10:50:27 -0400 |
commit | 1104a8855109a4051d74977f819a13b4516aa11e (patch) | |
tree | c81894968089f010c293bbba501a18e6331204e1 /fs/btrfs/ctree.h | |
parent | b6919a58f09db5daaa29b0326d53513ee418b84b (diff) |
btrfs: enhance superblock checks
The superblock checksum is not verified upon mount. <awkward silence>
Add that check and also reorder existing checks to a more logical
order.
Current mkfs.btrfs does not calculate the correct checksum of
super_block and thus a freshly created filesytem will fail to mount when
this patch is applied.
First transaction commit calculates correct superblock checksum and
saves it to disk.
Reproducer:
$ mfks.btrfs /dev/sda
$ mount /dev/sda /mnt
$ btrfs scrub start /mnt
$ sleep 5
$ btrfs scrub status /mnt
... super:2 ...
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 78b9d457d723..63c328a9ce95 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2793,8 +2793,10 @@ BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, | |||
2793 | 2793 | ||
2794 | static inline int btrfs_super_csum_size(struct btrfs_super_block *s) | 2794 | static inline int btrfs_super_csum_size(struct btrfs_super_block *s) |
2795 | { | 2795 | { |
2796 | int t = btrfs_super_csum_type(s); | 2796 | u16 t = btrfs_super_csum_type(s); |
2797 | BUG_ON(t >= ARRAY_SIZE(btrfs_csum_sizes)); | 2797 | /* |
2798 | * csum type is validated at mount time | ||
2799 | */ | ||
2798 | return btrfs_csum_sizes[t]; | 2800 | return btrfs_csum_sizes[t]; |
2799 | } | 2801 | } |
2800 | 2802 | ||