Re: [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume
From: kernel test robot <hidden>
Date: 2021-06-28 16:24:01
Also in:
oe-kbuild-all
Hi Qu, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on kdave/for-next] [also build test WARNING on v5.13 next-20210628] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Qu-Wenruo/btrfs-allow-BTRFS_IOC_SNAP_DESTROY_V2-to-remove-ghost-subvolume/20210628-181747 base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next config: arm-randconfig-r025-20210628 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4c92e31dd0f1bd152eda883af20ff7fbcaa14945) 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 # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://github.com/0day-ci/linux/commit/391ab0041fef5776e7517ab363701d6f86d9406b git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Qu-Wenruo/btrfs-allow-BTRFS_IOC_SNAP_DESTROY_V2-to-remove-ghost-subvolume/20210628-181747 git checkout 391ab0041fef5776e7517ab363701d6f86d9406b # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <redacted> All warnings (new ones prefixed by >>):
quoted
fs/btrfs/ioctl.c:2931:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ioctl.c:2967:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ioctl.c:2931:2: note: remove the 'if' if its condition is always false
if (test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ioctl.c:2911:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.
vim +2931 fs/btrfs/ioctl.c
2894
2895 /*
2896 * Special case that some subvolume has missing ORPHAN_ITEM, but its refs is
2897 * already 0 (without any ROOT_REF/BACKREF).
2898 * In that case such subvolume is only taking space while unable to be deleted.
2899 *
2900 * No reproducer to reproduce such corruption, but it won't hurt to cleanup them
2901 * as we can reuse existing code since we only need to insert an orphan item and
2902 * queue them to be deleted.
2903 */
2904 static int __cold remove_ghost_subvol(struct btrfs_fs_info *fs_info,
2905 u64 rootid)
2906 {
2907 struct btrfs_trans_handle *trans;
2908 struct btrfs_root *root;
2909 struct btrfs_path *path;
2910 struct btrfs_key key;
2911 int ret;
2912
2913 root = btrfs_get_fs_root(fs_info, rootid, false);
2914 if (IS_ERR(root)) {
2915 ret = PTR_ERR(root);
2916 return ret;
2917 }
2918
2919 /* A ghost subvolume is already a problem, better to output a warning */
2920 btrfs_warn(fs_info, "root %llu has no refs nor orphan item", rootid);
2921 if (btrfs_root_refs(&root->root_item) != 0) {
2922 /* We get some strange root */
2923 btrfs_warn(fs_info,
2924 "root %llu has %u refs, but no proper root backref",
2925 rootid, btrfs_root_refs(&root->root_item));
2926 ret = -EUCLEAN;
2927 goto out;
2928 }
2929
2930 /* Already has orphan inserted */2931 if (test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state))
2932 goto out;
2933
2934 path = btrfs_alloc_path();
2935 if (!path) {
2936 ret = -ENOMEM;
2937 goto out;
2938 }
2939 key.objectid = BTRFS_ORPHAN_OBJECTID;
2940 key.type = BTRFS_ORPHAN_ITEM_KEY;
2941 key.offset = rootid;
2942
2943 ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
2944 btrfs_free_path(path);
2945 /* Either error or there is already an orphan item */
2946 if (ret <= 0)
2947 goto out;
2948
2949 trans = btrfs_start_transaction(fs_info->tree_root, 1);
2950 if (IS_ERR(trans)) {
2951 ret = PTR_ERR(trans);
2952 goto out;
2953 }
2954
2955 ret = btrfs_insert_orphan_item(trans, fs_info->tree_root, rootid);
2956 if (ret < 0 && ret != -EEXIST) {
2957 btrfs_abort_transaction(trans, ret);
2958 goto end_trans;
2959 }
2960 ret = 0;
2961 btrfs_add_dead_root(root);
2962
2963 end_trans:
2964 btrfs_end_transaction(trans);
2965 out:
2966 btrfs_put_root(root);
2967 return ret;
2968 }
2969
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Attachments
- .config.gz [application/gzip] 35286 bytes