From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: fs/btrfs/ordered-data.c:342:7: warning: Local variable entry_end shadows outer function [shadowFunction]
Date: Wed, 26 Jan 2022 03:17:37 +0800 [thread overview]
Message-ID: <202201260251.TJQQuSWb-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 12270 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Guenter Roeck <linux@roeck-us.net>
CC: Palmer Dabbelt <palmerdabbelt@google.com>
Hi Guenter,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a08b41ab9e2e468647f78eb17c28e29b93006394
commit: a18b14d8886614b3c7d290c4cfc33389822b0535 riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
date: 6 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 6 months ago
compiler: riscv64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
In file included from fs/btrfs/ordered-data.c:
>> fs/btrfs/ordered-data.c:342:7: warning: Local variable entry_end shadows outer function [shadowFunction]
u64 entry_end;
^
fs/btrfs/ordered-data.c:23:12: note: Shadowed declaration
static u64 entry_end(struct btrfs_ordered_extent *entry)
^
fs/btrfs/ordered-data.c:342:7: note: Shadow variable
u64 entry_end;
^
vim +342 fs/btrfs/ordered-data.c
dc17ff8f11d129 Chris Mason 2008-01-08 302
163cf09c2a0ee5 Chris Mason 2010-11-28 303 /*
e65f152e434848 Qu Wenruo 2021-04-01 304 * Mark all ordered extents io inside the specified range finished.
163cf09c2a0ee5 Chris Mason 2010-11-28 305 *
e65f152e434848 Qu Wenruo 2021-04-01 306 * @page: The invovled page for the opeartion.
e65f152e434848 Qu Wenruo 2021-04-01 307 * For uncompressed buffered IO, the page status also needs to be
e65f152e434848 Qu Wenruo 2021-04-01 308 * updated to indicate whether the pending ordered io is finished.
e65f152e434848 Qu Wenruo 2021-04-01 309 * Can be NULL for direct IO and compressed write.
e65f152e434848 Qu Wenruo 2021-04-01 310 * For these cases, callers are ensured they won't execute the
e65f152e434848 Qu Wenruo 2021-04-01 311 * endio function twice.
e65f152e434848 Qu Wenruo 2021-04-01 312 * @finish_func: The function to be executed when all the IO of an ordered
e65f152e434848 Qu Wenruo 2021-04-01 313 * extent are finished.
163cf09c2a0ee5 Chris Mason 2010-11-28 314 *
e65f152e434848 Qu Wenruo 2021-04-01 315 * This function is called for endio, thus the range must have ordered
e65f152e434848 Qu Wenruo 2021-04-01 316 * extent(s) coveri it.
163cf09c2a0ee5 Chris Mason 2010-11-28 317 */
e65f152e434848 Qu Wenruo 2021-04-01 318 void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
e65f152e434848 Qu Wenruo 2021-04-01 319 struct page *page, u64 file_offset,
e65f152e434848 Qu Wenruo 2021-04-01 320 u64 num_bytes, btrfs_func_t finish_func,
e65f152e434848 Qu Wenruo 2021-04-01 321 bool uptodate)
163cf09c2a0ee5 Chris Mason 2010-11-28 322 {
7095821ee1f57d Nikolay Borisov 2020-06-03 323 struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
e65f152e434848 Qu Wenruo 2021-04-01 324 struct btrfs_fs_info *fs_info = inode->root->fs_info;
e65f152e434848 Qu Wenruo 2021-04-01 325 struct btrfs_workqueue *wq;
163cf09c2a0ee5 Chris Mason 2010-11-28 326 struct rb_node *node;
163cf09c2a0ee5 Chris Mason 2010-11-28 327 struct btrfs_ordered_extent *entry = NULL;
5fd02043553b02 Josef Bacik 2012-05-02 328 unsigned long flags;
e65f152e434848 Qu Wenruo 2021-04-01 329 u64 cur = file_offset;
e65f152e434848 Qu Wenruo 2021-04-01 330
e65f152e434848 Qu Wenruo 2021-04-01 331 if (btrfs_is_free_space_inode(inode))
e65f152e434848 Qu Wenruo 2021-04-01 332 wq = fs_info->endio_freespace_worker;
e65f152e434848 Qu Wenruo 2021-04-01 333 else
e65f152e434848 Qu Wenruo 2021-04-01 334 wq = fs_info->endio_write_workers;
e65f152e434848 Qu Wenruo 2021-04-01 335
e65f152e434848 Qu Wenruo 2021-04-01 336 if (page)
e65f152e434848 Qu Wenruo 2021-04-01 337 ASSERT(page->mapping && page_offset(page) <= file_offset &&
e65f152e434848 Qu Wenruo 2021-04-01 338 file_offset + num_bytes <= page_offset(page) + PAGE_SIZE);
163cf09c2a0ee5 Chris Mason 2010-11-28 339
5fd02043553b02 Josef Bacik 2012-05-02 340 spin_lock_irqsave(&tree->lock, flags);
e65f152e434848 Qu Wenruo 2021-04-01 341 while (cur < file_offset + num_bytes) {
e65f152e434848 Qu Wenruo 2021-04-01 @342 u64 entry_end;
e65f152e434848 Qu Wenruo 2021-04-01 343 u64 end;
e65f152e434848 Qu Wenruo 2021-04-01 344 u32 len;
e65f152e434848 Qu Wenruo 2021-04-01 345
e65f152e434848 Qu Wenruo 2021-04-01 346 node = tree_search(tree, cur);
e65f152e434848 Qu Wenruo 2021-04-01 347 /* No ordered extents@all */
58f74b2203d786 Qu Wenruo 2020-12-22 348 if (!node)
e65f152e434848 Qu Wenruo 2021-04-01 349 break;
163cf09c2a0ee5 Chris Mason 2010-11-28 350
163cf09c2a0ee5 Chris Mason 2010-11-28 351 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
e65f152e434848 Qu Wenruo 2021-04-01 352 entry_end = entry->file_offset + entry->num_bytes;
e65f152e434848 Qu Wenruo 2021-04-01 353 /*
e65f152e434848 Qu Wenruo 2021-04-01 354 * |<-- OE --->| |
e65f152e434848 Qu Wenruo 2021-04-01 355 * cur
e65f152e434848 Qu Wenruo 2021-04-01 356 * Go to next OE.
e65f152e434848 Qu Wenruo 2021-04-01 357 */
e65f152e434848 Qu Wenruo 2021-04-01 358 if (cur >= entry_end) {
e65f152e434848 Qu Wenruo 2021-04-01 359 node = rb_next(node);
e65f152e434848 Qu Wenruo 2021-04-01 360 /* No more ordered extents, exit */
e65f152e434848 Qu Wenruo 2021-04-01 361 if (!node)
e65f152e434848 Qu Wenruo 2021-04-01 362 break;
e65f152e434848 Qu Wenruo 2021-04-01 363 entry = rb_entry(node, struct btrfs_ordered_extent,
e65f152e434848 Qu Wenruo 2021-04-01 364 rb_node);
e65f152e434848 Qu Wenruo 2021-04-01 365
e65f152e434848 Qu Wenruo 2021-04-01 366 /* Go to next ordered extent and continue */
e65f152e434848 Qu Wenruo 2021-04-01 367 cur = entry->file_offset;
e65f152e434848 Qu Wenruo 2021-04-01 368 continue;
e65f152e434848 Qu Wenruo 2021-04-01 369 }
e65f152e434848 Qu Wenruo 2021-04-01 370 /*
e65f152e434848 Qu Wenruo 2021-04-01 371 * | |<--- OE --->|
e65f152e434848 Qu Wenruo 2021-04-01 372 * cur
e65f152e434848 Qu Wenruo 2021-04-01 373 * Go to the start of OE.
e65f152e434848 Qu Wenruo 2021-04-01 374 */
e65f152e434848 Qu Wenruo 2021-04-01 375 if (cur < entry->file_offset) {
e65f152e434848 Qu Wenruo 2021-04-01 376 cur = entry->file_offset;
e65f152e434848 Qu Wenruo 2021-04-01 377 continue;
163cf09c2a0ee5 Chris Mason 2010-11-28 378 }
e65f152e434848 Qu Wenruo 2021-04-01 379
e65f152e434848 Qu Wenruo 2021-04-01 380 /*
e65f152e434848 Qu Wenruo 2021-04-01 381 * Now we are definitely inside one ordered extent.
e65f152e434848 Qu Wenruo 2021-04-01 382 *
e65f152e434848 Qu Wenruo 2021-04-01 383 * |<--- OE --->|
e65f152e434848 Qu Wenruo 2021-04-01 384 * |
e65f152e434848 Qu Wenruo 2021-04-01 385 * cur
e65f152e434848 Qu Wenruo 2021-04-01 386 */
e65f152e434848 Qu Wenruo 2021-04-01 387 end = min(entry->file_offset + entry->num_bytes,
e65f152e434848 Qu Wenruo 2021-04-01 388 file_offset + num_bytes) - 1;
e65f152e434848 Qu Wenruo 2021-04-01 389 ASSERT(end + 1 - cur < U32_MAX);
e65f152e434848 Qu Wenruo 2021-04-01 390 len = end + 1 - cur;
e65f152e434848 Qu Wenruo 2021-04-01 391
e65f152e434848 Qu Wenruo 2021-04-01 392 if (page) {
e65f152e434848 Qu Wenruo 2021-04-01 393 /*
f57ad93735fd66 Qu Wenruo 2021-04-07 394 * Ordered (Private2) bit indicates whether we still
f57ad93735fd66 Qu Wenruo 2021-04-07 395 * have pending io unfinished for the ordered extent.
e65f152e434848 Qu Wenruo 2021-04-01 396 *
e65f152e434848 Qu Wenruo 2021-04-01 397 * If there's no such bit, we need to skip to next range.
e65f152e434848 Qu Wenruo 2021-04-01 398 */
b945a4637ec72a Qu Wenruo 2021-05-31 399 if (!btrfs_page_test_ordered(fs_info, page, cur, len)) {
e65f152e434848 Qu Wenruo 2021-04-01 400 cur += len;
e65f152e434848 Qu Wenruo 2021-04-01 401 continue;
e65f152e434848 Qu Wenruo 2021-04-01 402 }
b945a4637ec72a Qu Wenruo 2021-05-31 403 btrfs_page_clear_ordered(fs_info, page, cur, len);
e65f152e434848 Qu Wenruo 2021-04-01 404 }
e65f152e434848 Qu Wenruo 2021-04-01 405
e65f152e434848 Qu Wenruo 2021-04-01 406 /* Now we're fine to update the accounting */
e65f152e434848 Qu Wenruo 2021-04-01 407 if (unlikely(len > entry->bytes_left)) {
e65f152e434848 Qu Wenruo 2021-04-01 408 WARN_ON(1);
0b246afa62b0cf Jeff Mahoney 2016-06-22 409 btrfs_crit(fs_info,
e65f152e434848 Qu Wenruo 2021-04-01 410 "bad ordered extent accounting, root=%llu ino=%llu OE offset=%llu OE len=%llu to_dec=%u left=%llu",
e65f152e434848 Qu Wenruo 2021-04-01 411 inode->root->root_key.objectid,
e65f152e434848 Qu Wenruo 2021-04-01 412 btrfs_ino(inode),
e65f152e434848 Qu Wenruo 2021-04-01 413 entry->file_offset,
e65f152e434848 Qu Wenruo 2021-04-01 414 entry->num_bytes,
e65f152e434848 Qu Wenruo 2021-04-01 415 len, entry->bytes_left);
e65f152e434848 Qu Wenruo 2021-04-01 416 entry->bytes_left = 0;
e65f152e434848 Qu Wenruo 2021-04-01 417 } else {
e65f152e434848 Qu Wenruo 2021-04-01 418 entry->bytes_left -= len;
163cf09c2a0ee5 Chris Mason 2010-11-28 419 }
e65f152e434848 Qu Wenruo 2021-04-01 420
5fd02043553b02 Josef Bacik 2012-05-02 421 if (!uptodate)
5fd02043553b02 Josef Bacik 2012-05-02 422 set_bit(BTRFS_ORDERED_IOERR, &entry->flags);
5fd02043553b02 Josef Bacik 2012-05-02 423
58f74b2203d786 Qu Wenruo 2020-12-22 424 /*
e65f152e434848 Qu Wenruo 2021-04-01 425 * All the IO of the ordered extent is finished, we need to queue
e65f152e434848 Qu Wenruo 2021-04-01 426 * the finish_func to be executed.
58f74b2203d786 Qu Wenruo 2020-12-22 427 */
e65f152e434848 Qu Wenruo 2021-04-01 428 if (entry->bytes_left == 0) {
e65f152e434848 Qu Wenruo 2021-04-01 429 set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
e65f152e434848 Qu Wenruo 2021-04-01 430 cond_wake_up(&entry->wait);
e76edab7f059bc Elena Reshetova 2017-03-03 431 refcount_inc(&entry->refs);
e65f152e434848 Qu Wenruo 2021-04-01 432 spin_unlock_irqrestore(&tree->lock, flags);
e65f152e434848 Qu Wenruo 2021-04-01 433 btrfs_init_work(&entry->work, finish_func, NULL, NULL);
e65f152e434848 Qu Wenruo 2021-04-01 434 btrfs_queue_work(wq, &entry->work);
e65f152e434848 Qu Wenruo 2021-04-01 435 spin_lock_irqsave(&tree->lock, flags);
e65f152e434848 Qu Wenruo 2021-04-01 436 }
e65f152e434848 Qu Wenruo 2021-04-01 437 cur += len;
163cf09c2a0ee5 Chris Mason 2010-11-28 438 }
5fd02043553b02 Josef Bacik 2012-05-02 439 spin_unlock_irqrestore(&tree->lock, flags);
163cf09c2a0ee5 Chris Mason 2010-11-28 440 }
163cf09c2a0ee5 Chris Mason 2010-11-28 441
:::::: The code at line 342 was first introduced by commit
:::::: e65f152e43484807b4caf7300e70d882e4652566 btrfs: refactor how we finish ordered extent io for endio functions
:::::: TO: Qu Wenruo <wqu@suse.com>
:::::: CC: David Sterba <dsterba@suse.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
reply other threads:[~2022-01-25 19:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202201260251.TJQQuSWb-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.