From: kernel test robot <lkp@intel.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org
Subject: Re: [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume
Date: Tue, 29 Jun 2021 00:22:55 +0800 [thread overview]
Message-ID: <202106290046.mJUcdTSg-lkp@intel.com> (raw)
In-Reply-To: <20210628101637.349718-4-wqu@suse.com>
[-- Attachment #1: Type: text/plain, Size: 5109 bytes --]
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: x86_64-randconfig-a002-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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# 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=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> 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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 45377 bytes --]
next prev parent reply other threads:[~2021-06-28 16:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 10:16 [PATCH 0/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume Qu Wenruo
2021-06-28 10:16 ` [PATCH 1/3] btrfs: return -EINVAL if some user wants to remove uuid/data_reloc tree Qu Wenruo
2021-06-28 10:59 ` Anand Jain
2021-06-28 10:16 ` [PATCH 2/3] btrfs: remove dead comment on btrfs_add_dead_root() Qu Wenruo
2021-06-28 11:01 ` Anand Jain
2021-06-28 10:16 ` [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume Qu Wenruo
2021-06-28 16:22 ` kernel test robot [this message]
2021-06-28 16:23 ` kernel test robot
2021-06-29 7:04 ` [kbuild] " Dan Carpenter
2021-06-30 13:16 ` David Sterba
2021-06-30 13:26 ` Qu Wenruo
2021-06-30 13:30 ` David Sterba
2021-06-30 13:35 ` Qu Wenruo
2021-07-20 4:05 ` [PATCH 0/3] " Zygo Blaxell
2021-07-20 4:33 ` Qu Wenruo
2021-07-20 15:41 ` Zygo Blaxell
2021-07-20 22:40 ` Qu Wenruo
2021-08-20 5:45 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202106290046.mJUcdTSg-lkp@intel.com \
--to=lkp@intel.com \
--cc=clang-built-linux@googlegroups.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).