Re: [PATCH 2/4] btrfs: add numdevs= mount option.

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

 



Hi NeilBrown,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on ext3/fsnotify linus/master v5.14-rc5 next-20210806]
[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/NeilBrown/Attempt-to-make-progress-with-btrfs-dev-number-strangeness/20210809-120046
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: x86_64-randconfig-c001-20210809 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c5c3cdb9c92895a63993cee70d2dd776ff9519c3)
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://github.com/0day-ci/linux/commit/c5bae87ed5b72b9fd999fa935f477483da001f63
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review NeilBrown/Attempt-to-make-progress-with-btrfs-dev-number-strangeness/20210809-120046
        git checkout c5bae87ed5b72b9fd999fa935f477483da001f63
        # 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@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> fs/btrfs/ioctl.c:740:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (fs_info->num_devs == BTRFS_MANY_DEVS)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:742:6: note: uninitialized use occurs here
           if (ret < 0)
               ^~~
   fs/btrfs/ioctl.c:740:2: note: remove the 'if' if its condition is always true
           if (fs_info->num_devs == BTRFS_MANY_DEVS)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/btrfs/ioctl.c:725:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   1 warning generated.


vim +740 fs/btrfs/ioctl.c

   716	
   717	static int create_snapshot(struct btrfs_root *root, struct inode *dir,
   718				   struct dentry *dentry, bool readonly,
   719				   struct btrfs_qgroup_inherit *inherit)
   720	{
   721		struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
   722		struct inode *inode;
   723		struct btrfs_pending_snapshot *pending_snapshot;
   724		struct btrfs_trans_handle *trans;
   725		int ret;
   726	
   727		if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
   728			return -EINVAL;
   729	
   730		if (atomic_read(&root->nr_swapfiles)) {
   731			btrfs_warn(fs_info,
   732				   "cannot snapshot subvolume with active swapfile");
   733			return -ETXTBSY;
   734		}
   735	
   736		pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_KERNEL);
   737		if (!pending_snapshot)
   738			return -ENOMEM;
   739	
 > 740		if (fs_info->num_devs == BTRFS_MANY_DEVS)
   741			ret = get_anon_bdev(&pending_snapshot->anon_dev);
   742		if (ret < 0)
   743			goto free_pending;
   744		pending_snapshot->root_item = kzalloc(sizeof(struct btrfs_root_item),
   745				GFP_KERNEL);
   746		pending_snapshot->path = btrfs_alloc_path();
   747		if (!pending_snapshot->root_item || !pending_snapshot->path) {
   748			ret = -ENOMEM;
   749			goto free_pending;
   750		}
   751	
   752		btrfs_init_block_rsv(&pending_snapshot->block_rsv,
   753				     BTRFS_BLOCK_RSV_TEMP);
   754		/*
   755		 * 1 - parent dir inode
   756		 * 2 - dir entries
   757		 * 1 - root item
   758		 * 2 - root ref/backref
   759		 * 1 - root of snapshot
   760		 * 1 - UUID item
   761		 */
   762		ret = btrfs_subvolume_reserve_metadata(BTRFS_I(dir)->root,
   763						&pending_snapshot->block_rsv, 8,
   764						false);
   765		if (ret)
   766			goto free_pending;
   767	
   768		pending_snapshot->dentry = dentry;
   769		pending_snapshot->root = root;
   770		pending_snapshot->readonly = readonly;
   771		pending_snapshot->dir = dir;
   772		pending_snapshot->inherit = inherit;
   773	
   774		trans = btrfs_start_transaction(root, 0);
   775		if (IS_ERR(trans)) {
   776			ret = PTR_ERR(trans);
   777			goto fail;
   778		}
   779	
   780		spin_lock(&fs_info->trans_lock);
   781		list_add(&pending_snapshot->list,
   782			 &trans->transaction->pending_snapshots);
   783		spin_unlock(&fs_info->trans_lock);
   784	
   785		ret = btrfs_commit_transaction(trans);
   786		if (ret)
   787			goto fail;
   788	
   789		ret = pending_snapshot->error;
   790		if (ret)
   791			goto fail;
   792	
   793		ret = btrfs_orphan_cleanup(pending_snapshot->snap);
   794		if (ret)
   795			goto fail;
   796	
   797		inode = btrfs_lookup_dentry(d_inode(dentry->d_parent), dentry);
   798		if (IS_ERR(inode)) {
   799			ret = PTR_ERR(inode);
   800			goto fail;
   801		}
   802	
   803		d_instantiate(dentry, inode);
   804		ret = 0;
   805		pending_snapshot->anon_dev = 0;
   806	fail:
   807		/* Prevent double freeing of anon_dev */
   808		if (ret && pending_snapshot->snap)
   809			pending_snapshot->snap->anon_dev = 0;
   810		btrfs_put_root(pending_snapshot->snap);
   811		btrfs_subvolume_release_metadata(root, &pending_snapshot->block_rsv);
   812	free_pending:
   813		if (pending_snapshot->anon_dev)
   814			free_anon_bdev(pending_snapshot->anon_dev);
   815		kfree(pending_snapshot->root_item);
   816		btrfs_free_path(pending_snapshot->path);
   817		kfree(pending_snapshot);
   818	
   819		return ret;
   820	}
   821	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux