[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202108171047.0SC2CAbq-lkp@intel.com>
Date: Tue, 17 Aug 2021 10:37:55 +0800
From: kernel test robot <lkp@...el.com>
To: "Darrick J. Wong" <djwong@...nel.org>
Cc: clang-built-linux@...glegroups.com, kbuild-all@...ts.01.org,
"Darrick J. Wong" <darrick.wong@...cle.com>,
linux-kernel@...r.kernel.org
Subject: [djwong-xfs:dax-zeroinit-clear-poison-5.15 68/68]
fs/ext4/extents.c:4695:8: warning: variable 'max_blocks' is used
uninitialized whenever 'if' condition is true
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git dax-zeroinit-clear-poison-5.15
head: 6380ce8db23c88d70b9954ff66477719ea84bf3f
commit: 6380ce8db23c88d70b9954ff66477719ea84bf3f [68/68] ext4: use DAX block device zeroout for FSDAX file ZERO_RANGE operations
config: x86_64-randconfig-a011-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 44d0a99a12ec7ead4d2f5ef649ba05b40f6d463d)
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://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?id=6380ce8db23c88d70b9954ff66477719ea84bf3f
git remote add djwong-xfs https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git
git fetch --no-tags djwong-xfs dax-zeroinit-clear-poison-5.15
git checkout 6380ce8db23c88d70b9954ff66477719ea84bf3f
# 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@...el.com>
All warnings (new ones prefixed by >>):
>> fs/ext4/extents.c:4695:8: warning: variable 'max_blocks' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (ret || did_zeroout)
^~~~~~~~~~~~~~~~~~
fs/ext4/extents.c:4741:43: note: uninitialized use occurs here
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
^~~~~~~~~~
fs/ext4/extents.c:4695:4: note: remove the 'if' if its condition is always false
if (ret || did_zeroout)
^~~~~~~~~~~~~~~~~~~~~~~
>> fs/ext4/extents.c:4695:8: warning: variable 'max_blocks' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (ret || did_zeroout)
^~~
fs/ext4/extents.c:4741:43: note: uninitialized use occurs here
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
^~~~~~~~~~
fs/ext4/extents.c:4695:8: note: remove the '||' if its condition is always false
if (ret || did_zeroout)
^~~~~~
fs/ext4/extents.c:4638:25: note: initialize the variable 'max_blocks' to silence this warning
unsigned int max_blocks;
^
= 0
2 warnings generated.
vim +4695 fs/ext4/extents.c
4626
4627 /*
4628 * preallocate space for a file. This implements ext4's fallocate file
4629 * operation, which gets called from sys_fallocate system call.
4630 * For block-mapped files, posix_fallocate should fall back to the method
4631 * of writing zeroes to the required new blocks (the same behavior which is
4632 * expected for file systems which do not support fallocate() system call).
4633 */
4634 long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4635 {
4636 struct inode *inode = file_inode(file);
4637 loff_t new_size = 0;
4638 unsigned int max_blocks;
4639 int ret = 0;
4640 int flags;
4641 ext4_lblk_t lblk;
4642 unsigned int blkbits = inode->i_blkbits;
4643
4644 /*
4645 * Encrypted inodes can't handle collapse range or insert
4646 * range since we would need to re-encrypt blocks with a
4647 * different IV or XTS tweak (which are based on the logical
4648 * block number).
4649 */
4650 if (IS_ENCRYPTED(inode) &&
4651 (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
4652 return -EOPNOTSUPP;
4653
4654 /* Return error if mode is not supported */
4655 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
4656 FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
4657 FALLOC_FL_INSERT_RANGE))
4658 return -EOPNOTSUPP;
4659
4660 ext4_fc_start_update(inode);
4661
4662 if (mode & FALLOC_FL_PUNCH_HOLE) {
4663 ret = ext4_punch_hole(inode, offset, len);
4664 goto exit;
4665 }
4666
4667 ret = ext4_convert_inline_data(inode);
4668 if (ret)
4669 goto exit;
4670
4671 if (mode & FALLOC_FL_COLLAPSE_RANGE) {
4672 ret = ext4_collapse_range(inode, offset, len);
4673 goto exit;
4674 }
4675
4676 if (mode & FALLOC_FL_INSERT_RANGE) {
4677 ret = ext4_insert_range(inode, offset, len);
4678 goto exit;
4679 }
4680
4681 if (mode & FALLOC_FL_ZERO_RANGE) {
4682 /*
4683 * If the file is in DAX mode, try to use a DAX-specific
4684 * function to zero the region.
4685 */
4686 if (IS_DAX(inode)) {
4687 bool did_zeroout = false;
4688
4689 inode_lock(inode);
4690
4691 ret = dax_zeroinit_range(inode, offset, len,
4692 &did_zeroout, &ext4_iomap_report_ops);
4693 if (ret == -EINVAL)
4694 ret = 0;
> 4695 if (ret || did_zeroout)
4696 goto out;
4697
4698 inode_unlock(inode);
4699 }
4700 ret = ext4_zero_range(file, offset, len, mode);
4701 goto exit;
4702 }
4703 trace_ext4_fallocate_enter(inode, offset, len, mode);
4704 lblk = offset >> blkbits;
4705
4706 max_blocks = EXT4_MAX_BLOCKS(len, offset, blkbits);
4707 flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
4708
4709 inode_lock(inode);
4710
4711 /*
4712 * We only support preallocation for extent-based files only
4713 */
4714 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
4715 ret = -EOPNOTSUPP;
4716 goto out;
4717 }
4718
4719 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
4720 (offset + len > inode->i_size ||
4721 offset + len > EXT4_I(inode)->i_disksize)) {
4722 new_size = offset + len;
4723 ret = inode_newsize_ok(inode, new_size);
4724 if (ret)
4725 goto out;
4726 }
4727
4728 /* Wait all existing dio workers, newcomers will block on i_mutex */
4729 inode_dio_wait(inode);
4730
4731 ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, flags);
4732 if (ret)
4733 goto out;
4734
4735 if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
4736 ret = ext4_fc_commit(EXT4_SB(inode->i_sb)->s_journal,
4737 EXT4_I(inode)->i_sync_tid);
4738 }
4739 out:
4740 inode_unlock(inode);
4741 trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
4742 exit:
4743 ext4_fc_stop_update(inode);
4744 return ret;
4745 }
4746
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (33689 bytes)
Powered by blists - more mailing lists