Re: [PATCH] btrfs: tree-checker: Verify block_group_item

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Qu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on btrfs/next]
[also build test WARNING on v4.18-rc3 next-20180629]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Qu-Wenruo/btrfs-tree-checker-Verify-block_group_item/20180702-135502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git next
config: i386-randconfig-x016-201826 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   fs/btrfs/tree-checker.c: In function 'check_block_group_item':
>> fs/btrfs/tree-checker.c:402:41: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Wformat=]
       "invalid item size, have %u expect %lu",
                                          ~~^
                                          %u

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

   379	
   380	static int check_block_group_item(struct btrfs_fs_info *fs_info,
   381					  struct extent_buffer *leaf,
   382					  struct btrfs_key *key, int slot)
   383	{
   384		struct btrfs_block_group_item bgi;
   385		u32 item_size = btrfs_item_size_nr(leaf, slot);
   386		u64 flags;
   387	
   388		/*
   389		 * Here we don't really care about unalignment since extent allocator
   390		 * can handle it.
   391		 * We care more about the size, as if one block group is larger than
   392		 * maximum size, it's must be some obvious corruption
   393		 */
   394		if (key->offset > 10ULL * SZ_1G) {
   395			block_group_err(fs_info, leaf, slot,
   396				"invalid block group size, have %llu expect (0, %llu)",
   397					key->offset, 10ULL * SZ_1G);
   398			return -EUCLEAN;
   399		}
   400		if (item_size != sizeof(bgi)) {
   401			block_group_err(fs_info, leaf, slot,
 > 402				"invalid item size, have %u expect %lu",
   403					item_size, sizeof(bgi));
   404			return -EUCLEAN;
   405		}
   406		read_extent_buffer(leaf, &bgi, btrfs_item_ptr_offset(leaf, slot),
   407				   sizeof(bgi));
   408		if (btrfs_block_group_chunk_objectid(&bgi) !=
   409		    BTRFS_FIRST_CHUNK_TREE_OBJECTID) {
   410			block_group_err(fs_info, leaf, slot,
   411			"invalid block group chunk objectid, have %llu expect %llu",
   412					btrfs_block_group_chunk_objectid(&bgi),
   413					BTRFS_FIRST_CHUNK_TREE_OBJECTID);
   414			return -EUCLEAN;
   415		}
   416		if (btrfs_block_group_used(&bgi) > key->offset) {
   417			block_group_err(fs_info, leaf, slot,
   418				"invalid block group used, have %llu expect [0, %llu)",
   419					btrfs_block_group_used(&bgi), key->offset);
   420			return -EUCLEAN;
   421		}
   422		flags = btrfs_block_group_flags(&bgi);
   423		if (!((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 ||
   424		      hweight64(flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 1)) {
   425			block_group_err(fs_info, leaf, slot,
   426	"invalid profile flags, have 0x%llx (%lu bits set) expect no more than 1 bit set",
   427				flags & BTRFS_BLOCK_GROUP_PROFILE_MASK,
   428				hweight64(flags & BTRFS_BLOCK_GROUP_PROFILE_MASK));
   429			return -EUCLEAN;
   430		}
   431		if (hweight64(flags & BTRFS_BLOCK_GROUP_TYPE_MASK) != 1) {
   432			block_group_err(fs_info, leaf, slot,
   433	"invalid type flags, have 0x%llx (%lu bits set) expect exactly 1 bit set",
   434				flags & BTRFS_BLOCK_GROUP_TYPE_MASK,
   435				hweight64(flags & BTRFS_BLOCK_GROUP_TYPE_MASK));
   436			return -EUCLEAN;
   437		}
   438		return 0;
   439	}
   440	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux