[<prev] [next>] [day] [month] [year] [list]
Message-ID: <f90e6d91-e75d-8627-03a7-46525f8dda2e@intel.com>
Date: Fri, 5 Nov 2021 14:33:44 +0800
From: kernel test robot <yujie.liu@...el.com>
To: David Howells <dhowells@...hat.com>
CC: <kbuild-all@...ts.01.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [dhowells-fs:fscache-rewrite-indexing-3 43/55]
fs/cachefiles/io.c:490:6: warning: Uninitialized variable: ret [uninitvar]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-rewrite-indexing-3
head: d2eff33286af9373ec469be3146d6e122c07264f
commit: 54975963cf72ae83b33bc4dd298e234976a7e4cd [43/55] cachefiles: Implement the I/O routines
compiler: hppa64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> fs/cachefiles/io.c:490:6: warning: Uninitialized variable: ret [uninitvar]
if (ret < 0) {
^
vim +490 fs/cachefiles/io.c
54975963cf72ae David Howells 2021-10-21 427
54975963cf72ae David Howells 2021-10-21 428 /*
54975963cf72ae David Howells 2021-10-21 429 * Prepare for a write to occur.
54975963cf72ae David Howells 2021-10-21 430 */
54975963cf72ae David Howells 2021-10-21 431 static int __cachefiles_prepare_write(struct netfs_cache_resources *cres,
54975963cf72ae David Howells 2021-10-21 432 loff_t *_start, size_t *_len, loff_t i_size,
54975963cf72ae David Howells 2021-10-21 433 bool no_space_allocated_yet)
54975963cf72ae David Howells 2021-10-21 434 {
54975963cf72ae David Howells 2021-10-21 435 struct cachefiles_object *object = cachefiles_cres_object(cres);
54975963cf72ae David Howells 2021-10-21 436 struct cachefiles_cache *cache = object->volume->cache;
54975963cf72ae David Howells 2021-10-21 437 struct file *file = cachefiles_cres_file(cres);
54975963cf72ae David Howells 2021-10-21 438 loff_t start = *_start, pos;
54975963cf72ae David Howells 2021-10-21 439 size_t len = *_len, down;
54975963cf72ae David Howells 2021-10-21 440 int ret;
54975963cf72ae David Howells 2021-10-21 441
54975963cf72ae David Howells 2021-10-21 442 /* Round to DIO size */
54975963cf72ae David Howells 2021-10-21 443 down = start - round_down(start, PAGE_SIZE);
54975963cf72ae David Howells 2021-10-21 444 *_start = start - down;
54975963cf72ae David Howells 2021-10-21 445 *_len = round_up(down + len, PAGE_SIZE);
54975963cf72ae David Howells 2021-10-21 446
54975963cf72ae David Howells 2021-10-21 447 /* We need to work out whether there's sufficient disk space to perform
54975963cf72ae David Howells 2021-10-21 448 * the write - but we can skip that check if we have space already
54975963cf72ae David Howells 2021-10-21 449 * allocated.
54975963cf72ae David Howells 2021-10-21 450 */
54975963cf72ae David Howells 2021-10-21 451 if (no_space_allocated_yet)
54975963cf72ae David Howells 2021-10-21 452 goto check_space;
54975963cf72ae David Howells 2021-10-21 453
54975963cf72ae David Howells 2021-10-21 454 pos = cachefiles_inject_read_error();
54975963cf72ae David Howells 2021-10-21 455 if (pos == 0)
54975963cf72ae David Howells 2021-10-21 456 pos = vfs_llseek(file, *_start, SEEK_DATA);
54975963cf72ae David Howells 2021-10-21 457 if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
54975963cf72ae David Howells 2021-10-21 458 if (pos == -ENXIO)
54975963cf72ae David Howells 2021-10-21 459 goto check_space; /* Unallocated tail */
54975963cf72ae David Howells 2021-10-21 460 trace_cachefiles_io_error(object, file_inode(file), pos,
54975963cf72ae David Howells 2021-10-21 461 cachefiles_trace_seek_error);
54975963cf72ae David Howells 2021-10-21 462 return pos;
54975963cf72ae David Howells 2021-10-21 463 }
54975963cf72ae David Howells 2021-10-21 464 if ((u64)pos >= (u64)*_start + *_len)
54975963cf72ae David Howells 2021-10-21 465 goto check_space; /* Unallocated region */
54975963cf72ae David Howells 2021-10-21 466
54975963cf72ae David Howells 2021-10-21 467 /* We have a block that's at least partially filled - if we're low on
54975963cf72ae David Howells 2021-10-21 468 * space, we need to see if it's fully allocated. If it's not, we may
54975963cf72ae David Howells 2021-10-21 469 * want to cull it.
54975963cf72ae David Howells 2021-10-21 470 */
54975963cf72ae David Howells 2021-10-21 471 if (cachefiles_has_space(cache, 0, *_len / PAGE_SIZE) == 0)
54975963cf72ae David Howells 2021-10-21 472 return 0; /* Enough space to simply overwrite the whole block */
54975963cf72ae David Howells 2021-10-21 473
54975963cf72ae David Howells 2021-10-21 474 pos = cachefiles_inject_read_error();
54975963cf72ae David Howells 2021-10-21 475 if (pos == 0)
54975963cf72ae David Howells 2021-10-21 476 pos = vfs_llseek(file, *_start, SEEK_HOLE);
54975963cf72ae David Howells 2021-10-21 477 if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
54975963cf72ae David Howells 2021-10-21 478 trace_cachefiles_io_error(object, file_inode(file), pos,
54975963cf72ae David Howells 2021-10-21 479 cachefiles_trace_seek_error);
54975963cf72ae David Howells 2021-10-21 480 return pos;
54975963cf72ae David Howells 2021-10-21 481 }
54975963cf72ae David Howells 2021-10-21 482 if ((u64)pos >= (u64)*_start + *_len)
54975963cf72ae David Howells 2021-10-21 483 return 0; /* Fully allocated */
54975963cf72ae David Howells 2021-10-21 484
54975963cf72ae David Howells 2021-10-21 485 /* Partially allocated, but insufficient space: cull. */
54975963cf72ae David Howells 2021-10-21 486 pos = cachefiles_inject_remove_error();
54975963cf72ae David Howells 2021-10-21 487 if (pos == 0)
54975963cf72ae David Howells 2021-10-21 488 ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
54975963cf72ae David Howells 2021-10-21 489 *_start, *_len);
54975963cf72ae David Howells 2021-10-21 @490 if (ret < 0) {
54975963cf72ae David Howells 2021-10-21 491 trace_cachefiles_io_error(object, file_inode(file), ret,
54975963cf72ae David Howells 2021-10-21 492 cachefiles_trace_fallocate_error);
54975963cf72ae David Howells 2021-10-21 493 cachefiles_io_error_obj(object,
54975963cf72ae David Howells 2021-10-21 494 "CacheFiles: fallocate failed (%d)\n", ret);
54975963cf72ae David Howells 2021-10-21 495 ret = -EIO;
54975963cf72ae David Howells 2021-10-21 496 }
54975963cf72ae David Howells 2021-10-21 497
54975963cf72ae David Howells 2021-10-21 498 return ret;
54975963cf72ae David Howells 2021-10-21 499
54975963cf72ae David Howells 2021-10-21 500 check_space:
54975963cf72ae David Howells 2021-10-21 501 return cachefiles_has_space(cache, 0, *_len / PAGE_SIZE);
54975963cf72ae David Howells 2021-10-21 502 }
54975963cf72ae David Howells 2021-10-21 503
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists