Skip to content

btrfs: Add write time super block validation

Qu Wenruo linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 4 repliesIn review
  2. v33 patches 11 repliesSuperseded
  3. v24 patches 7 repliesSuperseded

Changes in v4 from the cover letter

Change the timing of btrfs_validate_write_super() to handle seed sprout case, where the original superblock can be from seed device, which has a different fsid. Thanks Anand for exposing this bug. Only the last patch is affected.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: Move btrfs_check_super_valid() to avoid forward declarationfs/btrfs/disk-io.c+149 -1500 replies
2/3btrfs: Refactor btrfs_check_super_valid()fs/btrfs/disk-io.c+25 -41 reply
3/3btrfs: Do super block verification before writing it to diskfs/btrfs/disk-io.c+43 -03 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchSu YueNikolay Borisov
1/3
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] btrfs: Add write time super block validation

This patchset can be fetched from github:
https://github.com/adam900710/linux/tree/write_time_sb_check

We have 2 reports about corrupted btrfs super block, which has some garbage in its super block, but otherwise it's completely fine and its csum even matches.

This means we develop memory corruption during btrfs mount time. It's not clear whether it's caused by btrfs or some other kernel module, but at least let's do write time verification to catch such corruption early.

Current design is to do 2 different checks at mount time and super write time.
And for write time check, it only checks the template super block (fs_info->super_to_commit) other than each super blocks to be written to disk, mostly to avoid duplicated checks.

Changelog:
v2:
Rename btrfs_check_super_valid() to btrfs_validate_super() suggested by Nikolay and David.
v3:
Add a new patch to move btrfs_check_super_valid() to avoid forward declaration.
Refactor btrfs_check_super_valid() to provide better naming and function reusablity.
Code style and comment update.
Use 2 different functions, btrfs_validate_mount_super() and btrfs_validate_write_super(), for mount and write time super check.
v4:
Change the timing of btrfs_validate_write_super() to handle seed sprout case, where the original superblock can be from seed device, which has a different fsid. Thanks Anand for exposing this bug. Only the last patch is affected.

Qu Wenruo (3):
btrfs: Move btrfs_check_super_valid() to avoid forward declaration
btrfs: Refactor btrfs_check_super_valid()
btrfs: Do super block verification before writing it to disk

 fs/btrfs/disk-io.c | 365 ++++++++++++++++++++++++++-------------------
 1 file changed, 214 insertions(+), 151 deletions(-)
Signature · 1 line
2.17.0