Re: [PATCH v2 2/2] f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl

From: kernel test robot
Date: Thu Oct 22 2020 - 02:51:35 EST


Hi Daeho,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on f2fs/dev-test]
[also build test WARNING on linus/master v5.9 next-20201022]
[cannot apply to linux/master]
[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/Daeho-Jeong/f2fs-add-F2FS_IOC_GET_COMPRESS_OPTION-ioctl/20201022-115947
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-randconfig-a005-20201022 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project ee6abef5323d59b983129bf3514ef6775d1d6cd5)
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/d869d11ac39edb97c13765c59163d12f56dccd6f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Daeho-Jeong/f2fs-add-F2FS_IOC_GET_COMPRESS_OPTION-ioctl/20201022-115947
git checkout d869d11ac39edb97c13765c59163d12f56dccd6f
# 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/f2fs/file.c:3997:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (f2fs_is_mmap_file(inode) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/file.c:4011:9: note: uninitialized use occurs here
return ret;
^~~
fs/f2fs/file.c:3997:2: note: remove the 'if' if its condition is always true
if (f2fs_is_mmap_file(inode) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/file.c:3974:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.

vim +3997 fs/f2fs/file.c

3968
3969 static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
3970 {
3971 struct inode *inode = file_inode(filp);
3972 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
3973 struct f2fs_comp_option option;
3974 int ret;
3975
3976 if (!f2fs_sb_has_compression(sbi))
3977 return -EOPNOTSUPP;
3978
3979 if (!f2fs_compressed_file(inode))
3980 return -EINVAL;
3981
3982 if (!(filp->f_mode & FMODE_WRITE))
3983 return -EBADF;
3984
3985 if (copy_from_user(&option, (struct f2fs_comp_option __user *)arg,
3986 sizeof(option)))
3987 return -EFAULT;
3988
3989 if (option.log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
3990 option.log_cluster_size > MAX_COMPRESS_LOG_SIZE ||
3991 !f2fs_is_compress_algorithm_ready(option.algorithm))
3992 return -EINVAL;
3993
3994 file_start_write(filp);
3995 inode_lock(inode);
3996
> 3997 if (f2fs_is_mmap_file(inode) ||
3998 get_dirty_pages(inode) || inode->i_size) {
3999 ret = -EINVAL;
4000 goto out;
4001 }
4002
4003 F2FS_I(inode)->i_compress_algorithm = option.algorithm;
4004 F2FS_I(inode)->i_log_cluster_size = option.log_cluster_size;
4005 F2FS_I(inode)->i_cluster_size = 1 << option.log_cluster_size;
4006 f2fs_mark_inode_dirty_sync(inode, true);
4007 out:
4008 inode_unlock(inode);
4009 file_end_write(filp);
4010
4011 return ret;
4012 }
4013

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

Attachment: .config.gz
Description: application/gzip