1. 25 Jul, 2024 1 commit
    • Qu Wenruo's avatar
      btrfs: tree-checker: validate dref root and objectid · f333a3c7
      Qu Wenruo authored
      [CORRUPTION]
      There is a bug report that btrfs flips RO due to a corruption in the
      extent tree, the involved dumps looks like this:
      
       	item 188 key (402811572224 168 4096) itemoff 14598 itemsize 79
       		extent refs 3 gen 3678544 flags 1
       		ref#0: extent data backref root 13835058055282163977 objectid 281473384125923 offset 81432576 count 1
       		ref#1: shared data backref parent 1947073626112 count 1
       		ref#2: shared data backref parent 1156030103552 count 1
       BTRFS critical (device vdc1: state EA): unable to find ref byte nr 402811572224 parent 0 root 265 owner 28703026 offset 81432576 slot 189
       BTRFS error (device vdc1: state EA): failed to run delayed ref for logical 402811572224 num_bytes 4096 type 178 action 2 ref_mod 1: -2
      
      [CAUSE]
      The corrupted entry is ref#0 of item 188.
      The root number 13835058055282163977 is beyond the upper limit for root
      items (the current limit is 1 << 48), and the objectid also looks
      suspicious.
      
      Only the offset and count is correct.
      
      [ENHANCEMENT]
      Although it's still unknown why we have such many bytes corrupted
      randomly, we can still enhance the tree-checker for data backrefs by:
      
      - Validate the root value
        For now there should only be 3 types of roots can have data backref:
        * subvolume trees
        * data reloc trees
        * root tree
          Only for v1 space cache
      
      - validate the objectid value
        The objectid should be a valid inode number.
      
      Hopefully we can catch such problem in the future with the new checkers.
      Reported-by: default avatarKai Krakow <hurikhan77@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CAMthOuPjg5RDT-G_LXeBBUUtzt3cq=JywF+D1_h+JYxe=WKp-Q@mail.gmail.com/#tReviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      f333a3c7
  2. 19 Jul, 2024 1 commit
    • Qu Wenruo's avatar
      btrfs: change BTRFS_MOUNT_* flags to 64bit type · c3ece6b7
      Qu Wenruo authored
      Currently the BTRFS_MOUNT_* flags are already beyond 32 bits, this is
      going to cause compilation errors for some 32 bit systems, as their
      unsigned long is only 32 bits long, thus flag
      BTRFS_MOUNT_IGNORESUPERFLAGS overflows and can lead to errors.
      
      Fix the problem by:
      
      - Migrate all existing BTRFS_MOUNT_* flags to unsigned long long
      - Migrate all mount option related variables to unsigned long long
        * btrfs_fs_info::mount_opt
        * btrfs_fs_context::mount_opt
        * mount_opt parameter of btrfs_check_options()
        * old_opts parameter of btrfs_remount_begin()
        * old_opts parameter of btrfs_remount_cleanup()
        * mount_opt parameter of btrfs_check_mountopts_zoned()
        * mount_opt and opt parameters of check_ro_option()
      
      Fixes: 32e62165 ("btrfs: introduce new "rescue=ignoresuperflags" mount option")
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      c3ece6b7
  3. 11 Jul, 2024 38 commits