* Dan Carpenter <dan.carpenter@xxxxxxxxxx>: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev > head: 0a76945fd1ba2ab44da7b578b311efdfedf92e6c > commit: 3258386aba670e3406a499d2d0b7395e14c8d097 [6/8] ext4: reset retry counter when ext4_alloc_file_blocks() makes progress > config: i386-randconfig-m021-20210215 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@xxxxxxxxx> > Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > > New smatch warnings: > fs/ext4/extents.c:4456 ext4_alloc_file_blocks() error: uninitialized symbol 'ret'. > > Old smatch warnings: > fs/ext4/extents.c:2396 ext4_rereserve_cluster() warn: should '(1) << sbi->s_cluster_bits' be a 64 bit type? > include/linux/fs.h:861 i_size_write() warn: statement has no effect 31 > fs/ext4/extents.c:5760 ext4_clu_mapped() warn: should 'lclu << sbi->s_cluster_bits' be a 64 bit type? > fs/ext4/extents.c:6009 ext4_ext_replay_set_iblocks() warn: should 'numblks << (inode->i_sb->s_blocksize_bits - 9)' be a 64 bit type? > > vim +/ret +4456 fs/ext4/extents.c > > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4379 static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4380 ext4_lblk_t len, loff_t new_size, > ^^^^^^^^^^^^^^^ > Can "len" be zero? If so then we have a problem, if not then this is > a false positive. This should be a false positive, but there's no reason not to silence this warning. I'll post a v2 correcting the original patch. Eric > > 77a2e84d51729d Tahsin Erdogan 2017-08-05 4381 int flags) > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4382 { > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4383 struct inode *inode = file_inode(file); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4384 handle_t *handle; > 3258386aba670e Eric Whitney 2021-01-13 4385 int ret, ret2 = 0, ret3 = 0; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4386 int retries = 0; > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4387 int depth = 0; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4388 struct ext4_map_blocks map; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4389 unsigned int credits; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4390 loff_t epos; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4391 > c3fe493ccdb1f4 Fabian Frederick 2016-09-15 4392 BUG_ON(!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4393 map.m_lblk = offset; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4394 map.m_len = len; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4395 /* > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4396 * Don't normalize the request if it can fit in one extent so > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4397 * that it doesn't get unnecessarily split into multiple > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4398 * extents. > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4399 */ > 556615dcbf38b0 Lukas Czerner 2014-04-20 4400 if (len <= EXT_UNWRITTEN_MAX_LEN) > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4401 flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4402 > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4403 /* > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4404 * credits to insert 1 extent into extent tree > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4405 */ > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4406 credits = ext4_chunk_trans_blocks(inode, len); > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4407 depth = ext_depth(inode); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4408 > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4409 retry: > 3258386aba670e Eric Whitney 2021-01-13 4410 while (len) { > ^^^^^^^^^^^^^ > > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4411 /* > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4412 * Recalculate credits when extent tree depth changes. > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4413 */ > 011c88e36c26a0 Dan Carpenter 2016-12-03 4414 if (depth != ext_depth(inode)) { > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4415 credits = ext4_chunk_trans_blocks(inode, len); > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4416 depth = ext_depth(inode); > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4417 } > 4134f5c88dcd5b Lukas Czerner 2015-06-15 4418 > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4419 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS, > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4420 credits); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4421 if (IS_ERR(handle)) { > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4422 ret = PTR_ERR(handle); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4423 break; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4424 } > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4425 ret = ext4_map_blocks(handle, inode, &map, flags); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4426 if (ret <= 0) { > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4427 ext4_debug("inode #%lu: block %u: len %u: " > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4428 "ext4_ext_map_blocks returned %d", > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4429 inode->i_ino, map.m_lblk, > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4430 map.m_len, ret); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4431 ext4_mark_inode_dirty(handle, inode); > 3258386aba670e Eric Whitney 2021-01-13 4432 ext4_journal_stop(handle); > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4433 break; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4434 } > 3258386aba670e Eric Whitney 2021-01-13 4435 /* > 3258386aba670e Eric Whitney 2021-01-13 4436 * allow a full retry cycle for any remaining allocations > 3258386aba670e Eric Whitney 2021-01-13 4437 */ > 3258386aba670e Eric Whitney 2021-01-13 4438 retries = 0; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4439 map.m_lblk += ret; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4440 map.m_len = len = len - ret; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4441 epos = (loff_t)map.m_lblk << inode->i_blkbits; > eeca7ea1baa939 Deepa Dinamani 2016-11-14 4442 inode->i_ctime = current_time(inode); > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4443 if (new_size) { > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4444 if (epos > new_size) > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4445 epos = new_size; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4446 if (ext4_update_inode_size(inode, epos) & 0x1) > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4447 inode->i_mtime = inode->i_ctime; > c174e6d6979a04 Dmitry Monakhov 2014-08-27 4448 } > 4209ae12b12265 Harshad Shirwadkar 2020-04-26 4449 ret2 = ext4_mark_inode_dirty(handle, inode); > c894aa97577e47 Eryu Guan 2017-12-03 4450 ext4_update_inode_fsync_trans(handle, inode, 1); > 4209ae12b12265 Harshad Shirwadkar 2020-04-26 4451 ret3 = ext4_journal_stop(handle); > 4209ae12b12265 Harshad Shirwadkar 2020-04-26 4452 ret2 = ret3 ? ret3 : ret2; > 4209ae12b12265 Harshad Shirwadkar 2020-04-26 4453 if (unlikely(ret2)) > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4454 break; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4455 } > 3258386aba670e Eric Whitney 2021-01-13 @4456 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) > ^^^^^^^^^^^^^^ > > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4457 goto retry; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4458 > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4459 return ret > 0 ? ret2 : ret; > 0e8b6879f3c234 Lukas Czerner 2014-03-18 4460 } > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx