tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   358feceebbf68f33c44c6650d14455389e65282d
commit: 1465af12e254a68706e110846f59cf0f09683184 btrfs: tree-checker: fix false 
alert caused by legacy btrfs root item
date:   4 months ago
config: i386-randconfig-a014-20200624 (attached as .config)
compiler: gcc-4.9 (Ubuntu 4.9.3-13ubuntu2) 4.9.3
reproduce (this is a W=1 build):
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1465af12e254a68706e110846f59cf0f09683184
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 1465af12e254a68706e110846f59cf0f09683184
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

   fs/btrfs/tree-checker.c: In function 'check_root_item':
>> fs/btrfs/tree-checker.c:1038:9: warning: missing braces around initializer 
>> [-Wmissing-braces]
     struct btrfs_root_item ri = { 0 };
            ^
   fs/btrfs/tree-checker.c:1038:9: warning: (near initialization for 
'ri.inode') [-Wmissing-braces]


vim +1038 fs/btrfs/tree-checker.c

  1033  
  1034  static int check_root_item(struct extent_buffer *leaf, struct btrfs_key 
*key,
  1035                             int slot)
  1036  {
  1037          struct btrfs_fs_info *fs_info = leaf->fs_info;
> 1038          struct btrfs_root_item ri = { 0 };
  1039          const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY |
  1040                                       BTRFS_ROOT_SUBVOL_DEAD;
  1041          int ret;
  1042  
  1043          ret = check_root_key(leaf, key, slot);
  1044          if (ret < 0)
  1045                  return ret;
  1046  
  1047          if (btrfs_item_size_nr(leaf, slot) != sizeof(ri) &&
  1048              btrfs_item_size_nr(leaf, slot) != 
btrfs_legacy_root_item_size()) {
  1049                  generic_err(leaf, slot,
  1050                              "invalid root item size, have %u expect %zu 
or %u",
  1051                              btrfs_item_size_nr(leaf, slot), sizeof(ri),
  1052                              btrfs_legacy_root_item_size());
  1053          }
  1054  
  1055          /*
  1056           * For legacy root item, the members starting at generation_v2 
will be
  1057           * all filled with 0.
  1058           * And since we allow geneartion_v2 as 0, it will still pass 
the check.
  1059           */
  1060          read_extent_buffer(leaf, &ri, btrfs_item_ptr_offset(leaf, slot),
  1061                             btrfs_item_size_nr(leaf, slot));
  1062  
  1063          /* Generation related */
  1064          if (btrfs_root_generation(&ri) >
  1065              btrfs_super_generation(fs_info->super_copy) + 1) {
  1066                  generic_err(leaf, slot,
  1067                          "invalid root generation, have %llu expect (0, 
%llu]",
  1068                              btrfs_root_generation(&ri),
  1069                              btrfs_super_generation(fs_info->super_copy) 
+ 1);
  1070                  return -EUCLEAN;
  1071          }
  1072          if (btrfs_root_generation_v2(&ri) >
  1073              btrfs_super_generation(fs_info->super_copy) + 1) {
  1074                  generic_err(leaf, slot,
  1075                  "invalid root v2 generation, have %llu expect (0, 
%llu]",
  1076                              btrfs_root_generation_v2(&ri),
  1077                              btrfs_super_generation(fs_info->super_copy) 
+ 1);
  1078                  return -EUCLEAN;
  1079          }
  1080          if (btrfs_root_last_snapshot(&ri) >
  1081              btrfs_super_generation(fs_info->super_copy) + 1) {
  1082                  generic_err(leaf, slot,
  1083                  "invalid root last_snapshot, have %llu expect (0, 
%llu]",
  1084                              btrfs_root_last_snapshot(&ri),
  1085                              btrfs_super_generation(fs_info->super_copy) 
+ 1);
  1086                  return -EUCLEAN;
  1087          }
  1088  
  1089          /* Alignment and level check */
  1090          if (!IS_ALIGNED(btrfs_root_bytenr(&ri), fs_info->sectorsize)) {
  1091                  generic_err(leaf, slot,
  1092                  "invalid root bytenr, have %llu expect to be aligned to 
%u",
  1093                              btrfs_root_bytenr(&ri), 
fs_info->sectorsize);
  1094                  return -EUCLEAN;
  1095          }
  1096          if (btrfs_root_level(&ri) >= BTRFS_MAX_LEVEL) {
  1097                  generic_err(leaf, slot,
  1098                              "invalid root level, have %u expect [0, 
%u]",
  1099                              btrfs_root_level(&ri), BTRFS_MAX_LEVEL - 1);
  1100                  return -EUCLEAN;
  1101          }
  1102          if (ri.drop_level >= BTRFS_MAX_LEVEL) {
  1103                  generic_err(leaf, slot,
  1104                              "invalid root level, have %u expect [0, 
%u]",
  1105                              ri.drop_level, BTRFS_MAX_LEVEL - 1);
  1106                  return -EUCLEAN;
  1107          }
  1108  
  1109          /* Flags check */
  1110          if (btrfs_root_flags(&ri) & ~valid_root_flags) {
  1111                  generic_err(leaf, slot,
  1112                              "invalid root flags, have 0x%llx expect 
mask 0x%llx",
  1113                              btrfs_root_flags(&ri), valid_root_flags);
  1114                  return -EUCLEAN;
  1115          }
  1116          return 0;
  1117  }
  1118  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

Reply via email to