All of lore.kernel.org
 help / color / mirror / Atom feed
* [fdmanana:misc-next 3/4] fs/btrfs/tree-log.c:4501:9: warning: Identical condition 'ret', second condition is always false
@ 2020-08-16 10:17 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-08-16 10:17 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 11738 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git misc-next
head:   e19a1a28c0327556bc78e4c5081dab9d5e557f1a
commit: 6105869e2ac5f5e4eeb3a7e2db001ce72a49df9a [3/4] btrfs: make fast fsyncs wait only for writeback
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)

>> fs/btrfs/tree-log.c:4501:9: warning: Identical condition 'ret', second condition is always false [identicalConditionAfterEarlyExit]
    return ret;
           ^
   fs/btrfs/tree-log.c:4476:6: note: first condition
    if (ret)
        ^
   fs/btrfs/tree-log.c:4501:9: note: second condition
    return ret;
           ^
   fs/btrfs/tree-log.c:2184:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
    ret = 0;
        ^
   fs/btrfs/tree-log.c:2162:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = 1;
        ^
   fs/btrfs/tree-log.c:2184:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = 0;
        ^
   fs/btrfs/tree-log.c:3547:6: warning: Variable 'log' is reassigned a value before the old one has been used. [redundantAssignment]
    log = root->log_root;
        ^
   fs/btrfs/tree-log.c:3537:0: note: Variable 'log' is reassigned a value before the old one has been used.
    struct btrfs_root *log = root->log_root;
   ^
   fs/btrfs/tree-log.c:3547:6: note: Variable 'log' is reassigned a value before the old one has been used.
    log = root->log_root;
        ^
   fs/btrfs/tree-log.c:5855:8: warning: Variable 'leaf' is reassigned a value before the old one has been used. [redundantAssignment]
     leaf = path->nodes[0];
          ^
   fs/btrfs/tree-log.c:5822:0: note: Variable 'leaf' is reassigned a value before the old one has been used.
     struct extent_buffer *leaf = path->nodes[0];
   ^
   fs/btrfs/tree-log.c:5855:8: note: Variable 'leaf' is reassigned a value before the old one has been used.
     leaf = path->nodes[0];
          ^
   fs/btrfs/tree-log.c:5856:8: warning: Variable 'slot' is reassigned a value before the old one has been used. [redundantAssignment]
     slot = path->slots[0];
          ^
   fs/btrfs/tree-log.c:5823:0: note: Variable 'slot' is reassigned a value before the old one has been used.
     int slot = path->slots[0];
   ^
   fs/btrfs/tree-log.c:5856:8: note: Variable 'slot' is reassigned a value before the old one has been used.
     slot = path->slots[0];
          ^

# https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git/commit/?id=6105869e2ac5f5e4eeb3a7e2db001ce72a49df9a
git remote add fdmanana https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git
git fetch --no-tags fdmanana misc-next
git checkout 6105869e2ac5f5e4eeb3a7e2db001ce72a49df9a
vim +/ret +4501 fs/btrfs/tree-log.c

31d11b83b96faa Filipe Manana   2018-05-09  4396  
5dc562c541e102 Josef Bacik     2012-08-17  4397  static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
5dc562c541e102 Josef Bacik     2012-08-17  4398  				     struct btrfs_root *root,
9d122629f1f65a Nikolay Borisov 2017-01-18  4399  				     struct btrfs_inode *inode,
827463c49f2911 Miao Xie        2014-01-14  4400  				     struct btrfs_path *path,
6105869e2ac5f5 Filipe Manana   2020-08-11  4401  				     struct btrfs_log_ctx *ctx)
5dc562c541e102 Josef Bacik     2012-08-17  4402  {
6105869e2ac5f5 Filipe Manana   2020-08-11  4403  	struct btrfs_ordered_extent *ordered;
6105869e2ac5f5 Filipe Manana   2020-08-11  4404  	struct btrfs_ordered_extent *tmp;
5dc562c541e102 Josef Bacik     2012-08-17  4405  	struct extent_map *em, *n;
5dc562c541e102 Josef Bacik     2012-08-17  4406  	struct list_head extents;
9d122629f1f65a Nikolay Borisov 2017-01-18  4407  	struct extent_map_tree *tree = &inode->extent_tree;
5dc562c541e102 Josef Bacik     2012-08-17  4408  	u64 test_gen;
5dc562c541e102 Josef Bacik     2012-08-17  4409  	int ret = 0;
2ab28f322f9896 Josef Bacik     2012-10-12  4410  	int num = 0;
5dc562c541e102 Josef Bacik     2012-08-17  4411  
5dc562c541e102 Josef Bacik     2012-08-17  4412  	INIT_LIST_HEAD(&extents);
5dc562c541e102 Josef Bacik     2012-08-17  4413  
5dc562c541e102 Josef Bacik     2012-08-17  4414  	write_lock(&tree->lock);
5dc562c541e102 Josef Bacik     2012-08-17  4415  	test_gen = root->fs_info->last_trans_committed;
5dc562c541e102 Josef Bacik     2012-08-17  4416  
5dc562c541e102 Josef Bacik     2012-08-17  4417  	list_for_each_entry_safe(em, n, &tree->modified_extents, list) {
5dc562c541e102 Josef Bacik     2012-08-17  4418  		list_del_init(&em->list);
2ab28f322f9896 Josef Bacik     2012-10-12  4419  		/*
2ab28f322f9896 Josef Bacik     2012-10-12  4420  		 * Just an arbitrary number, this can be really CPU intensive
2ab28f322f9896 Josef Bacik     2012-10-12  4421  		 * once we start getting a lot of extents, and really once we
2ab28f322f9896 Josef Bacik     2012-10-12  4422  		 * have a bunch of extents we just want to commit since it will
2ab28f322f9896 Josef Bacik     2012-10-12  4423  		 * be faster.
2ab28f322f9896 Josef Bacik     2012-10-12  4424  		 */
2ab28f322f9896 Josef Bacik     2012-10-12  4425  		if (++num > 32768) {
2ab28f322f9896 Josef Bacik     2012-10-12  4426  			list_del_init(&tree->modified_extents);
2ab28f322f9896 Josef Bacik     2012-10-12  4427  			ret = -EFBIG;
2ab28f322f9896 Josef Bacik     2012-10-12  4428  			goto process;
2ab28f322f9896 Josef Bacik     2012-10-12  4429  		}
2ab28f322f9896 Josef Bacik     2012-10-12  4430  
5dc562c541e102 Josef Bacik     2012-08-17  4431  		if (em->generation <= test_gen)
5dc562c541e102 Josef Bacik     2012-08-17  4432  			continue;
8c6c592831a09a Josef Bacik     2017-08-29  4433  
31d11b83b96faa Filipe Manana   2018-05-09  4434  		/* We log prealloc extents beyond eof later. */
31d11b83b96faa Filipe Manana   2018-05-09  4435  		if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags) &&
31d11b83b96faa Filipe Manana   2018-05-09  4436  		    em->start >= i_size_read(&inode->vfs_inode))
31d11b83b96faa Filipe Manana   2018-05-09  4437  			continue;
31d11b83b96faa Filipe Manana   2018-05-09  4438  
ff44c6e36dc9dc Josef Bacik     2012-09-14  4439  		/* Need a ref to keep it from getting evicted from cache */
490b54d6fb75f6 Elena Reshetova 2017-03-03  4440  		refcount_inc(&em->refs);
ff44c6e36dc9dc Josef Bacik     2012-09-14  4441  		set_bit(EXTENT_FLAG_LOGGING, &em->flags);
5dc562c541e102 Josef Bacik     2012-08-17  4442  		list_add_tail(&em->list, &extents);
2ab28f322f9896 Josef Bacik     2012-10-12  4443  		num++;
5dc562c541e102 Josef Bacik     2012-08-17  4444  	}
5dc562c541e102 Josef Bacik     2012-08-17  4445  
5dc562c541e102 Josef Bacik     2012-08-17  4446  	list_sort(NULL, &extents, extent_cmp);
2ab28f322f9896 Josef Bacik     2012-10-12  4447  process:
5dc562c541e102 Josef Bacik     2012-08-17  4448  	while (!list_empty(&extents)) {
5dc562c541e102 Josef Bacik     2012-08-17  4449  		em = list_entry(extents.next, struct extent_map, list);
5dc562c541e102 Josef Bacik     2012-08-17  4450  
5dc562c541e102 Josef Bacik     2012-08-17  4451  		list_del_init(&em->list);
5dc562c541e102 Josef Bacik     2012-08-17  4452  
5dc562c541e102 Josef Bacik     2012-08-17  4453  		/*
5dc562c541e102 Josef Bacik     2012-08-17  4454  		 * If we had an error we just need to delete everybody from our
5dc562c541e102 Josef Bacik     2012-08-17  4455  		 * private list.
5dc562c541e102 Josef Bacik     2012-08-17  4456  		 */
ff44c6e36dc9dc Josef Bacik     2012-09-14  4457  		if (ret) {
201a90389424d6 Josef Bacik     2013-01-24  4458  			clear_em_logging(tree, em);
ff44c6e36dc9dc Josef Bacik     2012-09-14  4459  			free_extent_map(em);
5dc562c541e102 Josef Bacik     2012-08-17  4460  			continue;
ff44c6e36dc9dc Josef Bacik     2012-09-14  4461  		}
ff44c6e36dc9dc Josef Bacik     2012-09-14  4462  
ff44c6e36dc9dc Josef Bacik     2012-09-14  4463  		write_unlock(&tree->lock);
5dc562c541e102 Josef Bacik     2012-08-17  4464  
a2120a473a8090 Josef Bacik     2018-05-23  4465  		ret = log_one_extent(trans, inode, root, em, path, ctx);
ff44c6e36dc9dc Josef Bacik     2012-09-14  4466  		write_lock(&tree->lock);
201a90389424d6 Josef Bacik     2013-01-24  4467  		clear_em_logging(tree, em);
201a90389424d6 Josef Bacik     2013-01-24  4468  		free_extent_map(em);
5dc562c541e102 Josef Bacik     2012-08-17  4469  	}
ff44c6e36dc9dc Josef Bacik     2012-09-14  4470  	WARN_ON(!list_empty(&extents));
ff44c6e36dc9dc Josef Bacik     2012-09-14  4471  	write_unlock(&tree->lock);
5dc562c541e102 Josef Bacik     2012-08-17  4472  
5dc562c541e102 Josef Bacik     2012-08-17  4473  	btrfs_release_path(path);
31d11b83b96faa Filipe Manana   2018-05-09  4474  	if (!ret)
31d11b83b96faa Filipe Manana   2018-05-09  4475  		ret = btrfs_log_prealloc_extents(trans, inode, path);
6105869e2ac5f5 Filipe Manana   2020-08-11  4476  	if (ret)
6105869e2ac5f5 Filipe Manana   2020-08-11  4477  		return ret;
6105869e2ac5f5 Filipe Manana   2020-08-11  4478  
6105869e2ac5f5 Filipe Manana   2020-08-11  4479  	/*
6105869e2ac5f5 Filipe Manana   2020-08-11  4480  	 * We have logged all extents successfully, now make sure the commit of
6105869e2ac5f5 Filipe Manana   2020-08-11  4481  	 * the current transaction waits for the ordered extents to complete
6105869e2ac5f5 Filipe Manana   2020-08-11  4482  	 * before it commits and wipes out the log trees, otherwise we would
6105869e2ac5f5 Filipe Manana   2020-08-11  4483  	 * lose data if an ordered extents completes after the transaction
6105869e2ac5f5 Filipe Manana   2020-08-11  4484  	 * commits and a power failure happens after the transaction commit.
6105869e2ac5f5 Filipe Manana   2020-08-11  4485  	 */
6105869e2ac5f5 Filipe Manana   2020-08-11  4486  	list_for_each_entry_safe(ordered, tmp, &ctx->ordered_extents, log_list) {
6105869e2ac5f5 Filipe Manana   2020-08-11  4487  		list_del_init(&ordered->log_list);
6105869e2ac5f5 Filipe Manana   2020-08-11  4488  		set_bit(BTRFS_ORDERED_LOGGED, &ordered->flags);
6105869e2ac5f5 Filipe Manana   2020-08-11  4489  
6105869e2ac5f5 Filipe Manana   2020-08-11  4490  		if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) {
6105869e2ac5f5 Filipe Manana   2020-08-11  4491  			spin_lock_irq(&inode->ordered_tree.lock);
6105869e2ac5f5 Filipe Manana   2020-08-11  4492  			if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) {
6105869e2ac5f5 Filipe Manana   2020-08-11  4493  				set_bit(BTRFS_ORDERED_PENDING, &ordered->flags);
6105869e2ac5f5 Filipe Manana   2020-08-11  4494  				atomic_inc(&trans->transaction->pending_ordered);
6105869e2ac5f5 Filipe Manana   2020-08-11  4495  			}
6105869e2ac5f5 Filipe Manana   2020-08-11  4496  			spin_unlock_irq(&inode->ordered_tree.lock);
6105869e2ac5f5 Filipe Manana   2020-08-11  4497  		}
6105869e2ac5f5 Filipe Manana   2020-08-11  4498  		btrfs_put_ordered_extent(ordered);
6105869e2ac5f5 Filipe Manana   2020-08-11  4499  	}
31d11b83b96faa Filipe Manana   2018-05-09  4500  
5dc562c541e102 Josef Bacik     2012-08-17 @4501  	return ret;
5dc562c541e102 Josef Bacik     2012-08-17  4502  }
5dc562c541e102 Josef Bacik     2012-08-17  4503  

:::::: The code at line 4501 was first introduced by commit
:::::: 5dc562c541e1026df9d43913c2f6b91156e22d32 Btrfs: turbo charge fsync

:::::: TO: Josef Bacik <jbacik@fusionio.com>
:::::: CC: Chris Mason <chris.mason@fusionio.com>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-16 10:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16 10:17 [fdmanana:misc-next 3/4] fs/btrfs/tree-log.c:4501:9: warning: Identical condition 'ret', second condition is always false kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.