* [PATCH] btrfs: Simplify setup_nodes_for_search
@ 2020-05-27 10:11 Nikolay Borisov
2020-05-27 12:56 ` Johannes Thumshirn
0 siblings, 1 reply; 8+ messages in thread
From: Nikolay Borisov @ 2020-05-27 10:11 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
The function is needlessly convoluted. Fix that by:
* Removing redundant sret variable definition in both if arms
* Replace the again/done labels with direct return statements, the
function is short enough and doesn't do anything special upon exit.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 72a3389d2d87..bd1d54e6b4cc 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2436,55 +2436,46 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
- int sret;
if (*write_lock_level < level + 1) {
*write_lock_level = level + 1;
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
btrfs_set_path_blocking(p);
reada_for_balance(fs_info, p, level);
- sret = split_node(trans, root, p, level);
+ ret = split_node(trans, root, p, level);
+
+ BUG_ON(ret > 0);
+ if (ret)
+ return ret;
- BUG_ON(sret > 0);
- if (sret) {
- ret = sret;
- goto done;
- }
b = p->nodes[level];
} else if (ins_len < 0 && btrfs_header_nritems(b) <
BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
- int sret;
if (*write_lock_level < level + 1) {
*write_lock_level = level + 1;
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
btrfs_set_path_blocking(p);
reada_for_balance(fs_info, p, level);
- sret = balance_level(trans, root, p, level);
+ ret = balance_level(trans, root, p, level);
+
+ if (ret)
+ return ret;
- if (sret) {
- ret = sret;
- goto done;
- }
b = p->nodes[level];
if (!b) {
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
BUG_ON(btrfs_header_nritems(b) == 1);
}
return 0;
-
-again:
- ret = -EAGAIN;
-done:
- return ret;
}
int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
2020-05-27 10:11 [PATCH] btrfs: Simplify setup_nodes_for_search Nikolay Borisov
@ 2020-05-27 12:56 ` Johannes Thumshirn
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2020-05-27 12:56 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
Highly appreciated,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
2020-11-12 11:16 Nikolay Borisov
@ 2020-11-13 5:06 ` kernel test robot
2020-11-13 3:30 ` kernel test robot
2020-11-13 5:06 ` kernel test robot
2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-11-13 5:06 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
Cc: kbuild-all, clang-built-linux, Nikolay Borisov
[-- Attachment #1: Type: text/plain, Size: 14025 bytes --]
Hi Nikolay,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20201112]
[cannot apply to btrfs/next v5.10-rc3]
[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/Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: riscv-randconfig-r014-20201112 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a7b65741441556d295079fc4f2391d99fd1c1111)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
git checkout aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
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 >>):
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:564:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inw(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:56:76: note: expanded from macro 'inw'
#define inw(c) ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:88:76: note: expanded from macro 'readw_cpu'
#define readw_cpu(c) ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:9: note: remove the 'if' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:13: note: remove the '&&' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~
fs/btrfs/ctree.c:2393:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
9 warnings generated.
vim +2408 fs/btrfs/ctree.c
c8c42864f619363 Chris Mason 2009-04-03 2376
c8c42864f619363 Chris Mason 2009-04-03 2377 /*
c8c42864f619363 Chris Mason 2009-04-03 2378 * helper function for btrfs_search_slot. This does all of the checks
c8c42864f619363 Chris Mason 2009-04-03 2379 * for node-level blocks and does any balancing required based on
c8c42864f619363 Chris Mason 2009-04-03 2380 * the ins_len.
c8c42864f619363 Chris Mason 2009-04-03 2381 *
c8c42864f619363 Chris Mason 2009-04-03 2382 * If no extra work was required, zero is returned. If we had to
c8c42864f619363 Chris Mason 2009-04-03 2383 * drop the path, -EAGAIN is returned and btrfs_search_slot must
c8c42864f619363 Chris Mason 2009-04-03 2384 * start over
c8c42864f619363 Chris Mason 2009-04-03 2385 */
c8c42864f619363 Chris Mason 2009-04-03 2386 static int
c8c42864f619363 Chris Mason 2009-04-03 2387 setup_nodes_for_search(struct btrfs_trans_handle *trans,
c8c42864f619363 Chris Mason 2009-04-03 2388 struct btrfs_root *root, struct btrfs_path *p,
bd681513fa6f2ff Chris Mason 2011-07-16 2389 struct extent_buffer *b, int level, int ins_len,
bd681513fa6f2ff Chris Mason 2011-07-16 2390 int *write_lock_level)
c8c42864f619363 Chris Mason 2009-04-03 2391 {
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2392 struct btrfs_fs_info *fs_info = root->fs_info;
c8c42864f619363 Chris Mason 2009-04-03 2393 int ret;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2394
c8c42864f619363 Chris Mason 2009-04-03 2395 if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2396 BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
c8c42864f619363 Chris Mason 2009-04-03 2397
bd681513fa6f2ff Chris Mason 2011-07-16 2398 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2399 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2400 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2401 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2402 }
bd681513fa6f2ff Chris Mason 2011-07-16 2403
480b65236526f4c Josef Bacik 2020-11-05 2404 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2405 ret = split_node(trans, root, p, level);
c8c42864f619363 Chris Mason 2009-04-03 2406
c8c42864f619363 Chris Mason 2009-04-03 2407 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 @2408 } else if (ins_len < 0 && btrfs_header_nritems(b) <
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2409 BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
c8c42864f619363 Chris Mason 2009-04-03 2410
bd681513fa6f2ff Chris Mason 2011-07-16 2411 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2412 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2413 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2414 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2415 }
bd681513fa6f2ff Chris Mason 2011-07-16 2416
480b65236526f4c Josef Bacik 2020-11-05 2417 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2418 ret = balance_level(trans, root, p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2419 if (ret)
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2420 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2421
c8c42864f619363 Chris Mason 2009-04-03 2422 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 2423 if (!b) {
b3b4aa74b58bded David Sterba 2011-04-21 2424 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2425 return -EAGAIN;
c8c42864f619363 Chris Mason 2009-04-03 2426 }
c8c42864f619363 Chris Mason 2009-04-03 2427 BUG_ON(btrfs_header_nritems(b) == 1);
c8c42864f619363 Chris Mason 2009-04-03 2428 }
c8c42864f619363 Chris Mason 2009-04-03 2429 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2430 }
c8c42864f619363 Chris Mason 2009-04-03 2431
---
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: 27148 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
@ 2020-11-13 5:06 ` kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-11-13 5:06 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 14245 bytes --]
Hi Nikolay,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20201112]
[cannot apply to btrfs/next v5.10-rc3]
[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/Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: riscv-randconfig-r014-20201112 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a7b65741441556d295079fc4f2391d99fd1c1111)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
git checkout aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
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 >>):
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:564:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inw(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:56:76: note: expanded from macro 'inw'
#define inw(c) ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:88:76: note: expanded from macro 'readw_cpu'
#define readw_cpu(c) ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:9: note: remove the 'if' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:13: note: remove the '&&' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~
fs/btrfs/ctree.c:2393:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
9 warnings generated.
vim +2408 fs/btrfs/ctree.c
c8c42864f619363 Chris Mason 2009-04-03 2376
c8c42864f619363 Chris Mason 2009-04-03 2377 /*
c8c42864f619363 Chris Mason 2009-04-03 2378 * helper function for btrfs_search_slot. This does all of the checks
c8c42864f619363 Chris Mason 2009-04-03 2379 * for node-level blocks and does any balancing required based on
c8c42864f619363 Chris Mason 2009-04-03 2380 * the ins_len.
c8c42864f619363 Chris Mason 2009-04-03 2381 *
c8c42864f619363 Chris Mason 2009-04-03 2382 * If no extra work was required, zero is returned. If we had to
c8c42864f619363 Chris Mason 2009-04-03 2383 * drop the path, -EAGAIN is returned and btrfs_search_slot must
c8c42864f619363 Chris Mason 2009-04-03 2384 * start over
c8c42864f619363 Chris Mason 2009-04-03 2385 */
c8c42864f619363 Chris Mason 2009-04-03 2386 static int
c8c42864f619363 Chris Mason 2009-04-03 2387 setup_nodes_for_search(struct btrfs_trans_handle *trans,
c8c42864f619363 Chris Mason 2009-04-03 2388 struct btrfs_root *root, struct btrfs_path *p,
bd681513fa6f2ff Chris Mason 2011-07-16 2389 struct extent_buffer *b, int level, int ins_len,
bd681513fa6f2ff Chris Mason 2011-07-16 2390 int *write_lock_level)
c8c42864f619363 Chris Mason 2009-04-03 2391 {
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2392 struct btrfs_fs_info *fs_info = root->fs_info;
c8c42864f619363 Chris Mason 2009-04-03 2393 int ret;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2394
c8c42864f619363 Chris Mason 2009-04-03 2395 if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2396 BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
c8c42864f619363 Chris Mason 2009-04-03 2397
bd681513fa6f2ff Chris Mason 2011-07-16 2398 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2399 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2400 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2401 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2402 }
bd681513fa6f2ff Chris Mason 2011-07-16 2403
480b65236526f4c Josef Bacik 2020-11-05 2404 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2405 ret = split_node(trans, root, p, level);
c8c42864f619363 Chris Mason 2009-04-03 2406
c8c42864f619363 Chris Mason 2009-04-03 2407 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 @2408 } else if (ins_len < 0 && btrfs_header_nritems(b) <
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2409 BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
c8c42864f619363 Chris Mason 2009-04-03 2410
bd681513fa6f2ff Chris Mason 2011-07-16 2411 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2412 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2413 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2414 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2415 }
bd681513fa6f2ff Chris Mason 2011-07-16 2416
480b65236526f4c Josef Bacik 2020-11-05 2417 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2418 ret = balance_level(trans, root, p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2419 if (ret)
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2420 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2421
c8c42864f619363 Chris Mason 2009-04-03 2422 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 2423 if (!b) {
b3b4aa74b58bded David Sterba 2011-04-21 2424 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2425 return -EAGAIN;
c8c42864f619363 Chris Mason 2009-04-03 2426 }
c8c42864f619363 Chris Mason 2009-04-03 2427 BUG_ON(btrfs_header_nritems(b) == 1);
c8c42864f619363 Chris Mason 2009-04-03 2428 }
c8c42864f619363 Chris Mason 2009-04-03 2429 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2430 }
c8c42864f619363 Chris Mason 2009-04-03 2431
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 27148 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
2020-11-12 11:16 Nikolay Borisov
@ 2020-11-13 3:30 ` kernel test robot
2020-11-13 3:30 ` kernel test robot
2020-11-13 5:06 ` kernel test robot
2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-11-13 3:30 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
Cc: kbuild-all, clang-built-linux, Nikolay Borisov
[-- Attachment #1: Type: text/plain, Size: 13301 bytes --]
Hi Nikolay,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20201112]
[cannot apply to v5.10-rc3]
[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/Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: riscv-randconfig-r011-20201112 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a7b65741441556d295079fc4f2391d99fd1c1111)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
git checkout aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
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 >>):
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:9: note: remove the 'if' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:13: note: remove the '&&' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~
fs/btrfs/ctree.c:2393:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
9 warnings generated.
vim +2408 fs/btrfs/ctree.c
c8c42864f619363 Chris Mason 2009-04-03 2376
c8c42864f619363 Chris Mason 2009-04-03 2377 /*
c8c42864f619363 Chris Mason 2009-04-03 2378 * helper function for btrfs_search_slot. This does all of the checks
c8c42864f619363 Chris Mason 2009-04-03 2379 * for node-level blocks and does any balancing required based on
c8c42864f619363 Chris Mason 2009-04-03 2380 * the ins_len.
c8c42864f619363 Chris Mason 2009-04-03 2381 *
c8c42864f619363 Chris Mason 2009-04-03 2382 * If no extra work was required, zero is returned. If we had to
c8c42864f619363 Chris Mason 2009-04-03 2383 * drop the path, -EAGAIN is returned and btrfs_search_slot must
c8c42864f619363 Chris Mason 2009-04-03 2384 * start over
c8c42864f619363 Chris Mason 2009-04-03 2385 */
c8c42864f619363 Chris Mason 2009-04-03 2386 static int
c8c42864f619363 Chris Mason 2009-04-03 2387 setup_nodes_for_search(struct btrfs_trans_handle *trans,
c8c42864f619363 Chris Mason 2009-04-03 2388 struct btrfs_root *root, struct btrfs_path *p,
bd681513fa6f2ff Chris Mason 2011-07-16 2389 struct extent_buffer *b, int level, int ins_len,
bd681513fa6f2ff Chris Mason 2011-07-16 2390 int *write_lock_level)
c8c42864f619363 Chris Mason 2009-04-03 2391 {
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2392 struct btrfs_fs_info *fs_info = root->fs_info;
c8c42864f619363 Chris Mason 2009-04-03 2393 int ret;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2394
c8c42864f619363 Chris Mason 2009-04-03 2395 if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2396 BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
c8c42864f619363 Chris Mason 2009-04-03 2397
bd681513fa6f2ff Chris Mason 2011-07-16 2398 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2399 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2400 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2401 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2402 }
bd681513fa6f2ff Chris Mason 2011-07-16 2403
480b65236526f4c Josef Bacik 2020-11-05 2404 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2405 ret = split_node(trans, root, p, level);
c8c42864f619363 Chris Mason 2009-04-03 2406
c8c42864f619363 Chris Mason 2009-04-03 2407 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 @2408 } else if (ins_len < 0 && btrfs_header_nritems(b) <
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2409 BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
c8c42864f619363 Chris Mason 2009-04-03 2410
bd681513fa6f2ff Chris Mason 2011-07-16 2411 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2412 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2413 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2414 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2415 }
bd681513fa6f2ff Chris Mason 2011-07-16 2416
480b65236526f4c Josef Bacik 2020-11-05 2417 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2418 ret = balance_level(trans, root, p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2419 if (ret)
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2420 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2421
c8c42864f619363 Chris Mason 2009-04-03 2422 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 2423 if (!b) {
b3b4aa74b58bded David Sterba 2011-04-21 2424 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2425 return -EAGAIN;
c8c42864f619363 Chris Mason 2009-04-03 2426 }
c8c42864f619363 Chris Mason 2009-04-03 2427 BUG_ON(btrfs_header_nritems(b) == 1);
c8c42864f619363 Chris Mason 2009-04-03 2428 }
c8c42864f619363 Chris Mason 2009-04-03 2429 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2430 }
c8c42864f619363 Chris Mason 2009-04-03 2431
---
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: 29302 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
@ 2020-11-13 3:30 ` kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2020-11-13 3:30 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 13512 bytes --]
Hi Nikolay,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20201112]
[cannot apply to v5.10-rc3]
[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/Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: riscv-randconfig-r011-20201112 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a7b65741441556d295079fc4f2391d99fd1c1111)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nikolay-Borisov/btrfs-Simplify-setup_nodes_for_search/20201112-191847
git checkout aea2237f4b88d91fc8ad6469b205ff6ada2fcf55
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
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 >>):
^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return inl(addr);
^~~~~~~~~
arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
#define inl(c) ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
#define readl_cpu(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outb(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
#define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
#define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outw(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
#define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
#define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
outl(value, addr);
^~~~~~~~~~~~~~~~~
arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
#define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
~~~~~~~~~~ ^
arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
#define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
^
In file included from fs/btrfs/ctree.c:10:
In file included from fs/btrfs/ctree.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:13:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/riscv/include/asm/io.h:149:
include/asm-generic/io.h:1005:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:9: note: remove the 'if' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/btrfs/ctree.c:2408:13: warning: variable 'ret' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~
fs/btrfs/ctree.c:2429:9: note: uninitialized use occurs here
return ret;
^~~
fs/btrfs/ctree.c:2408:13: note: remove the '&&' if its condition is always true
} else if (ins_len < 0 && btrfs_header_nritems(b) <
^~~~~~~~~~~~~~
fs/btrfs/ctree.c:2393:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
9 warnings generated.
vim +2408 fs/btrfs/ctree.c
c8c42864f619363 Chris Mason 2009-04-03 2376
c8c42864f619363 Chris Mason 2009-04-03 2377 /*
c8c42864f619363 Chris Mason 2009-04-03 2378 * helper function for btrfs_search_slot. This does all of the checks
c8c42864f619363 Chris Mason 2009-04-03 2379 * for node-level blocks and does any balancing required based on
c8c42864f619363 Chris Mason 2009-04-03 2380 * the ins_len.
c8c42864f619363 Chris Mason 2009-04-03 2381 *
c8c42864f619363 Chris Mason 2009-04-03 2382 * If no extra work was required, zero is returned. If we had to
c8c42864f619363 Chris Mason 2009-04-03 2383 * drop the path, -EAGAIN is returned and btrfs_search_slot must
c8c42864f619363 Chris Mason 2009-04-03 2384 * start over
c8c42864f619363 Chris Mason 2009-04-03 2385 */
c8c42864f619363 Chris Mason 2009-04-03 2386 static int
c8c42864f619363 Chris Mason 2009-04-03 2387 setup_nodes_for_search(struct btrfs_trans_handle *trans,
c8c42864f619363 Chris Mason 2009-04-03 2388 struct btrfs_root *root, struct btrfs_path *p,
bd681513fa6f2ff Chris Mason 2011-07-16 2389 struct extent_buffer *b, int level, int ins_len,
bd681513fa6f2ff Chris Mason 2011-07-16 2390 int *write_lock_level)
c8c42864f619363 Chris Mason 2009-04-03 2391 {
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2392 struct btrfs_fs_info *fs_info = root->fs_info;
c8c42864f619363 Chris Mason 2009-04-03 2393 int ret;
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2394
c8c42864f619363 Chris Mason 2009-04-03 2395 if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2396 BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
c8c42864f619363 Chris Mason 2009-04-03 2397
bd681513fa6f2ff Chris Mason 2011-07-16 2398 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2399 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2400 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2401 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2402 }
bd681513fa6f2ff Chris Mason 2011-07-16 2403
480b65236526f4c Josef Bacik 2020-11-05 2404 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2405 ret = split_node(trans, root, p, level);
c8c42864f619363 Chris Mason 2009-04-03 2406
c8c42864f619363 Chris Mason 2009-04-03 2407 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 @2408 } else if (ins_len < 0 && btrfs_header_nritems(b) <
0b246afa62b0cf5 Jeff Mahoney 2016-06-22 2409 BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
c8c42864f619363 Chris Mason 2009-04-03 2410
bd681513fa6f2ff Chris Mason 2011-07-16 2411 if (*write_lock_level < level + 1) {
bd681513fa6f2ff Chris Mason 2011-07-16 2412 *write_lock_level = level + 1;
bd681513fa6f2ff Chris Mason 2011-07-16 2413 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2414 return -EAGAIN;
bd681513fa6f2ff Chris Mason 2011-07-16 2415 }
bd681513fa6f2ff Chris Mason 2011-07-16 2416
480b65236526f4c Josef Bacik 2020-11-05 2417 reada_for_balance(p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2418 ret = balance_level(trans, root, p, level);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2419 if (ret)
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2420 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2421
c8c42864f619363 Chris Mason 2009-04-03 2422 b = p->nodes[level];
c8c42864f619363 Chris Mason 2009-04-03 2423 if (!b) {
b3b4aa74b58bded David Sterba 2011-04-21 2424 btrfs_release_path(p);
aea2237f4b88d91 Nikolay Borisov 2020-11-12 2425 return -EAGAIN;
c8c42864f619363 Chris Mason 2009-04-03 2426 }
c8c42864f619363 Chris Mason 2009-04-03 2427 BUG_ON(btrfs_header_nritems(b) == 1);
c8c42864f619363 Chris Mason 2009-04-03 2428 }
c8c42864f619363 Chris Mason 2009-04-03 2429 return ret;
c8c42864f619363 Chris Mason 2009-04-03 2430 }
c8c42864f619363 Chris Mason 2009-04-03 2431
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29302 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: Simplify setup_nodes_for_search
2020-11-12 11:16 Nikolay Borisov
@ 2020-11-12 12:17 ` Johannes Thumshirn
2020-11-13 3:30 ` kernel test robot
2020-11-13 5:06 ` kernel test robot
2 siblings, 0 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2020-11-12 12:17 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
Can't spot any errors,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] btrfs: Simplify setup_nodes_for_search
@ 2020-11-12 11:16 Nikolay Borisov
2020-11-12 12:17 ` Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Nikolay Borisov @ 2020-11-12 11:16 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
The function is needlessly convoluted. Fix that by:
* Removing redundant sret variable definition in both if arms.
* Replace the again/done labels with direct return statements, the
function is short enough and doesn't do anything special upon exit.
* Remove BUG_ON on split_node returning a positive number - it can't
happen as split_node returns either 0 or a negative error code.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 892b467347a3..6c309dfee3f5 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2394,52 +2394,38 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
if ((p->search_for_split || ins_len > 0) && btrfs_header_nritems(b) >=
BTRFS_NODEPTRS_PER_BLOCK(fs_info) - 3) {
- int sret;
if (*write_lock_level < level + 1) {
*write_lock_level = level + 1;
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
reada_for_balance(p, level);
- sret = split_node(trans, root, p, level);
+ ret = split_node(trans, root, p, level);
- BUG_ON(sret > 0);
- if (sret) {
- ret = sret;
- goto done;
- }
b = p->nodes[level];
} else if (ins_len < 0 && btrfs_header_nritems(b) <
BTRFS_NODEPTRS_PER_BLOCK(fs_info) / 2) {
- int sret;
if (*write_lock_level < level + 1) {
*write_lock_level = level + 1;
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
reada_for_balance(p, level);
- sret = balance_level(trans, root, p, level);
+ ret = balance_level(trans, root, p, level);
+ if (ret)
+ return ret;
- if (sret) {
- ret = sret;
- goto done;
- }
b = p->nodes[level];
if (!b) {
btrfs_release_path(p);
- goto again;
+ return -EAGAIN;
}
BUG_ON(btrfs_header_nritems(b) == 1);
}
- return 0;
-
-again:
- ret = -EAGAIN;
-done:
return ret;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-11-13 5:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:11 [PATCH] btrfs: Simplify setup_nodes_for_search Nikolay Borisov
2020-05-27 12:56 ` Johannes Thumshirn
2020-11-12 11:16 Nikolay Borisov
2020-11-12 12:17 ` Johannes Thumshirn
2020-11-13 3:30 ` kernel test robot
2020-11-13 3:30 ` kernel test robot
2020-11-13 5:06 ` kernel test robot
2020-11-13 5:06 ` 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.