[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202302230527.yIU4JpoR-lkp@intel.com>
Date: Thu, 23 Feb 2023 05:56:15 +0800
From: kernel test robot <lkp@...el.com>
To: Josef Bacik <josef@...icpanda.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
David Sterba <dsterba@...e.com>, Qu Wenruo <wqu@...e.com>
Subject: fs/btrfs/tree-log.c:4867:23: warning: 'start_slot' may be used
uninitialized
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 23064dfe088e0926e3fc0922f118866dc1564405
commit: 1ec49744ba83f0429c5c706708610f7821a7b6f4 btrfs: turn on -Wmaybe-uninitialized
date: 9 days ago
config: arm-randconfig-r015-20230222 (https://download.01.org/0day-ci/archive/20230223/202302230527.yIU4JpoR-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1ec49744ba83f0429c5c706708610f7821a7b6f4
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 1ec49744ba83f0429c5c706708610f7821a7b6f4
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash fs/btrfs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202302230527.yIU4JpoR-lkp@intel.com/
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
fs/btrfs/tree-log.c: In function 'btrfs_log_prealloc_extents':
>> fs/btrfs/tree-log.c:4867:23: warning: 'start_slot' may be used uninitialized [-Wmaybe-uninitialized]
4867 | ret = copy_items(trans, inode, dst_path, path,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4868 | start_slot, ins_nr, 1, 0);
| ~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/tree-log.c:4764:13: note: 'start_slot' was declared here
4764 | int start_slot;
| ^~~~~~~~~~
vim +/start_slot +4867 fs/btrfs/tree-log.c
8407f553268a46 Filipe Manana 2014-09-05 4741
31d11b83b96faa Filipe Manana 2018-05-09 4742 /*
31d11b83b96faa Filipe Manana 2018-05-09 4743 * Log all prealloc extents beyond the inode's i_size to make sure we do not
d99478874355d3 Filipe Manana 2022-02-17 4744 * lose them after doing a full/fast fsync and replaying the log. We scan the
31d11b83b96faa Filipe Manana 2018-05-09 4745 * subvolume's root instead of iterating the inode's extent map tree because
31d11b83b96faa Filipe Manana 2018-05-09 4746 * otherwise we can log incorrect extent items based on extent map conversion.
31d11b83b96faa Filipe Manana 2018-05-09 4747 * That can happen due to the fact that extent maps are merged when they
31d11b83b96faa Filipe Manana 2018-05-09 4748 * are not in the extent map tree's list of modified extents.
31d11b83b96faa Filipe Manana 2018-05-09 4749 */
31d11b83b96faa Filipe Manana 2018-05-09 4750 static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
31d11b83b96faa Filipe Manana 2018-05-09 4751 struct btrfs_inode *inode,
31d11b83b96faa Filipe Manana 2018-05-09 4752 struct btrfs_path *path)
31d11b83b96faa Filipe Manana 2018-05-09 4753 {
31d11b83b96faa Filipe Manana 2018-05-09 4754 struct btrfs_root *root = inode->root;
31d11b83b96faa Filipe Manana 2018-05-09 4755 struct btrfs_key key;
31d11b83b96faa Filipe Manana 2018-05-09 4756 const u64 i_size = i_size_read(&inode->vfs_inode);
31d11b83b96faa Filipe Manana 2018-05-09 4757 const u64 ino = btrfs_ino(inode);
31d11b83b96faa Filipe Manana 2018-05-09 4758 struct btrfs_path *dst_path = NULL;
0e56315ca147b3 Filipe Manana 2019-11-19 4759 bool dropped_extents = false;
f135cea30de5f7 Filipe Manana 2020-04-23 4760 u64 truncate_offset = i_size;
f135cea30de5f7 Filipe Manana 2020-04-23 4761 struct extent_buffer *leaf;
f135cea30de5f7 Filipe Manana 2020-04-23 4762 int slot;
31d11b83b96faa Filipe Manana 2018-05-09 4763 int ins_nr = 0;
31d11b83b96faa Filipe Manana 2018-05-09 4764 int start_slot;
31d11b83b96faa Filipe Manana 2018-05-09 4765 int ret;
31d11b83b96faa Filipe Manana 2018-05-09 4766
31d11b83b96faa Filipe Manana 2018-05-09 4767 if (!(inode->flags & BTRFS_INODE_PREALLOC))
31d11b83b96faa Filipe Manana 2018-05-09 4768 return 0;
31d11b83b96faa Filipe Manana 2018-05-09 4769
31d11b83b96faa Filipe Manana 2018-05-09 4770 key.objectid = ino;
31d11b83b96faa Filipe Manana 2018-05-09 4771 key.type = BTRFS_EXTENT_DATA_KEY;
31d11b83b96faa Filipe Manana 2018-05-09 4772 key.offset = i_size;
31d11b83b96faa Filipe Manana 2018-05-09 4773 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
31d11b83b96faa Filipe Manana 2018-05-09 4774 if (ret < 0)
31d11b83b96faa Filipe Manana 2018-05-09 4775 goto out;
31d11b83b96faa Filipe Manana 2018-05-09 4776
f135cea30de5f7 Filipe Manana 2020-04-23 4777 /*
f135cea30de5f7 Filipe Manana 2020-04-23 4778 * We must check if there is a prealloc extent that starts before the
f135cea30de5f7 Filipe Manana 2020-04-23 4779 * i_size and crosses the i_size boundary. This is to ensure later we
f135cea30de5f7 Filipe Manana 2020-04-23 4780 * truncate down to the end of that extent and not to the i_size, as
f135cea30de5f7 Filipe Manana 2020-04-23 4781 * otherwise we end up losing part of the prealloc extent after a log
f135cea30de5f7 Filipe Manana 2020-04-23 4782 * replay and with an implicit hole if there is another prealloc extent
f135cea30de5f7 Filipe Manana 2020-04-23 4783 * that starts at an offset beyond i_size.
f135cea30de5f7 Filipe Manana 2020-04-23 4784 */
f135cea30de5f7 Filipe Manana 2020-04-23 4785 ret = btrfs_previous_item(root, path, ino, BTRFS_EXTENT_DATA_KEY);
f135cea30de5f7 Filipe Manana 2020-04-23 4786 if (ret < 0)
f135cea30de5f7 Filipe Manana 2020-04-23 4787 goto out;
f135cea30de5f7 Filipe Manana 2020-04-23 4788
f135cea30de5f7 Filipe Manana 2020-04-23 4789 if (ret == 0) {
f135cea30de5f7 Filipe Manana 2020-04-23 4790 struct btrfs_file_extent_item *ei;
f135cea30de5f7 Filipe Manana 2020-04-23 4791
f135cea30de5f7 Filipe Manana 2020-04-23 4792 leaf = path->nodes[0];
f135cea30de5f7 Filipe Manana 2020-04-23 4793 slot = path->slots[0];
f135cea30de5f7 Filipe Manana 2020-04-23 4794 ei = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
f135cea30de5f7 Filipe Manana 2020-04-23 4795
f135cea30de5f7 Filipe Manana 2020-04-23 4796 if (btrfs_file_extent_type(leaf, ei) ==
f135cea30de5f7 Filipe Manana 2020-04-23 4797 BTRFS_FILE_EXTENT_PREALLOC) {
f135cea30de5f7 Filipe Manana 2020-04-23 4798 u64 extent_end;
f135cea30de5f7 Filipe Manana 2020-04-23 4799
f135cea30de5f7 Filipe Manana 2020-04-23 4800 btrfs_item_key_to_cpu(leaf, &key, slot);
f135cea30de5f7 Filipe Manana 2020-04-23 4801 extent_end = key.offset +
f135cea30de5f7 Filipe Manana 2020-04-23 4802 btrfs_file_extent_num_bytes(leaf, ei);
f135cea30de5f7 Filipe Manana 2020-04-23 4803
f135cea30de5f7 Filipe Manana 2020-04-23 4804 if (extent_end > i_size)
f135cea30de5f7 Filipe Manana 2020-04-23 4805 truncate_offset = extent_end;
f135cea30de5f7 Filipe Manana 2020-04-23 4806 }
f135cea30de5f7 Filipe Manana 2020-04-23 4807 } else {
f135cea30de5f7 Filipe Manana 2020-04-23 4808 ret = 0;
f135cea30de5f7 Filipe Manana 2020-04-23 4809 }
f135cea30de5f7 Filipe Manana 2020-04-23 4810
31d11b83b96faa Filipe Manana 2018-05-09 4811 while (true) {
f135cea30de5f7 Filipe Manana 2020-04-23 4812 leaf = path->nodes[0];
f135cea30de5f7 Filipe Manana 2020-04-23 4813 slot = path->slots[0];
31d11b83b96faa Filipe Manana 2018-05-09 4814
31d11b83b96faa Filipe Manana 2018-05-09 4815 if (slot >= btrfs_header_nritems(leaf)) {
31d11b83b96faa Filipe Manana 2018-05-09 4816 if (ins_nr > 0) {
31d11b83b96faa Filipe Manana 2018-05-09 4817 ret = copy_items(trans, inode, dst_path, path,
0e56315ca147b3 Filipe Manana 2019-11-19 4818 start_slot, ins_nr, 1, 0);
31d11b83b96faa Filipe Manana 2018-05-09 4819 if (ret < 0)
31d11b83b96faa Filipe Manana 2018-05-09 4820 goto out;
31d11b83b96faa Filipe Manana 2018-05-09 4821 ins_nr = 0;
31d11b83b96faa Filipe Manana 2018-05-09 4822 }
31d11b83b96faa Filipe Manana 2018-05-09 4823 ret = btrfs_next_leaf(root, path);
31d11b83b96faa Filipe Manana 2018-05-09 4824 if (ret < 0)
31d11b83b96faa Filipe Manana 2018-05-09 4825 goto out;
31d11b83b96faa Filipe Manana 2018-05-09 4826 if (ret > 0) {
31d11b83b96faa Filipe Manana 2018-05-09 4827 ret = 0;
31d11b83b96faa Filipe Manana 2018-05-09 4828 break;
31d11b83b96faa Filipe Manana 2018-05-09 4829 }
31d11b83b96faa Filipe Manana 2018-05-09 4830 continue;
31d11b83b96faa Filipe Manana 2018-05-09 4831 }
31d11b83b96faa Filipe Manana 2018-05-09 4832
31d11b83b96faa Filipe Manana 2018-05-09 4833 btrfs_item_key_to_cpu(leaf, &key, slot);
31d11b83b96faa Filipe Manana 2018-05-09 4834 if (key.objectid > ino)
31d11b83b96faa Filipe Manana 2018-05-09 4835 break;
31d11b83b96faa Filipe Manana 2018-05-09 4836 if (WARN_ON_ONCE(key.objectid < ino) ||
31d11b83b96faa Filipe Manana 2018-05-09 4837 key.type < BTRFS_EXTENT_DATA_KEY ||
31d11b83b96faa Filipe Manana 2018-05-09 4838 key.offset < i_size) {
31d11b83b96faa Filipe Manana 2018-05-09 4839 path->slots[0]++;
31d11b83b96faa Filipe Manana 2018-05-09 4840 continue;
31d11b83b96faa Filipe Manana 2018-05-09 4841 }
0e56315ca147b3 Filipe Manana 2019-11-19 4842 if (!dropped_extents) {
31d11b83b96faa Filipe Manana 2018-05-09 4843 /*
31d11b83b96faa Filipe Manana 2018-05-09 4844 * Avoid logging extent items logged in past fsync calls
31d11b83b96faa Filipe Manana 2018-05-09 4845 * and leading to duplicate keys in the log tree.
31d11b83b96faa Filipe Manana 2018-05-09 4846 */
8a2b3da191e5a1 Filipe Manana 2021-08-31 4847 ret = truncate_inode_items(trans, root->log_root, inode,
8a2b3da191e5a1 Filipe Manana 2021-08-31 4848 truncate_offset,
8a2b3da191e5a1 Filipe Manana 2021-08-31 4849 BTRFS_EXTENT_DATA_KEY);
31d11b83b96faa Filipe Manana 2018-05-09 4850 if (ret)
31d11b83b96faa Filipe Manana 2018-05-09 4851 goto out;
0e56315ca147b3 Filipe Manana 2019-11-19 4852 dropped_extents = true;
31d11b83b96faa Filipe Manana 2018-05-09 4853 }
31d11b83b96faa Filipe Manana 2018-05-09 4854 if (ins_nr == 0)
31d11b83b96faa Filipe Manana 2018-05-09 4855 start_slot = slot;
31d11b83b96faa Filipe Manana 2018-05-09 4856 ins_nr++;
31d11b83b96faa Filipe Manana 2018-05-09 4857 path->slots[0]++;
31d11b83b96faa Filipe Manana 2018-05-09 4858 if (!dst_path) {
31d11b83b96faa Filipe Manana 2018-05-09 4859 dst_path = btrfs_alloc_path();
31d11b83b96faa Filipe Manana 2018-05-09 4860 if (!dst_path) {
31d11b83b96faa Filipe Manana 2018-05-09 4861 ret = -ENOMEM;
31d11b83b96faa Filipe Manana 2018-05-09 4862 goto out;
31d11b83b96faa Filipe Manana 2018-05-09 4863 }
31d11b83b96faa Filipe Manana 2018-05-09 4864 }
31d11b83b96faa Filipe Manana 2018-05-09 4865 }
0bc2d3c08e2b97 Filipe Manana 2020-04-21 4866 if (ins_nr > 0)
0e56315ca147b3 Filipe Manana 2019-11-19 @4867 ret = copy_items(trans, inode, dst_path, path,
31d11b83b96faa Filipe Manana 2018-05-09 4868 start_slot, ins_nr, 1, 0);
31d11b83b96faa Filipe Manana 2018-05-09 4869 out:
31d11b83b96faa Filipe Manana 2018-05-09 4870 btrfs_release_path(path);
31d11b83b96faa Filipe Manana 2018-05-09 4871 btrfs_free_path(dst_path);
31d11b83b96faa Filipe Manana 2018-05-09 4872 return ret;
31d11b83b96faa Filipe Manana 2018-05-09 4873 }
31d11b83b96faa Filipe Manana 2018-05-09 4874
:::::: The code at line 4867 was first introduced by commit
:::::: 0e56315ca147b3e60c7bf240233a301d3c7fb508 Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES
:::::: TO: Filipe Manana <fdmanana@...e.com>
:::::: CC: David Sterba <dsterba@...e.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Powered by blists - more mailing lists