CC: [email protected] In-Reply-To: <[email protected]> References: <[email protected]> TO: Qu Wenruo <[email protected]>
Hi Qu, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on kdave/for-next] [also build test WARNING on next-20220107] [cannot apply to v5.16-rc8] [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/Qu-Wenruo/btrfs-refactor-scrub-entrances-for-each-profile/20220107-103545 base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next :::::: branch date: 24 hours ago :::::: commit date: 24 hours ago config: x86_64-randconfig-m001-20220107 (https://download.01.org/0day-ci/archive/20220108/[email protected]/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> New smatch warnings: fs/btrfs/scrub.c:3678 scrub_stripe() error: uninitialized symbol 'offset'. fs/btrfs/scrub.c:3680 scrub_stripe() error: uninitialized symbol 'physical_end'. Old smatch warnings: fs/btrfs/scrub.c:3439 scrub_simple_mirror() error: uninitialized symbol 'ret'. vim +/offset +3678 fs/btrfs/scrub.c 38e821991b4eb7 Qu Wenruo 2022-01-07 3512 d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3513 static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, 471a5e456ff42e Qu Wenruo 2021-12-15 3514 struct btrfs_block_group *bg, a36cf8b8933e4a Stefan Behrens 2012-11-02 3515 struct map_lookup *map, a36cf8b8933e4a Stefan Behrens 2012-11-02 3516 struct btrfs_device *scrub_dev, 471a5e456ff42e Qu Wenruo 2021-12-15 3517 int stripe_index, u64 dev_extent_len) a2de733c78fa7a Arne Jansen 2011-03-08 3518 { 69765031000981 Qu Wenruo 2021-12-14 3519 struct btrfs_path *path; fb456252d3d9c0 Jeff Mahoney 2016-06-22 3520 struct btrfs_fs_info *fs_info = sctx->fs_info; 29cbcf401793f4 Josef Bacik 2021-11-05 3521 struct btrfs_root *root; fc28b25e1f4286 Josef Bacik 2021-11-05 3522 struct btrfs_root *csum_root; e7786c3ae517b2 Arne Jansen 2011-05-28 3523 struct blk_plug plug; f8636fcdd5f4ab Qu Wenruo 2022-01-07 3524 const u64 profile = map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK; 471a5e456ff42e Qu Wenruo 2021-12-15 3525 const u64 chunk_logical = bg->start; a2de733c78fa7a Arne Jansen 2011-03-08 3526 int ret; a2de733c78fa7a Arne Jansen 2011-03-08 3527 u64 nstripes; a2de733c78fa7a Arne Jansen 2011-03-08 3528 u64 physical; a2de733c78fa7a Arne Jansen 2011-03-08 3529 u64 logical; 625f1c8dc66d77 Liu Bo 2013-04-27 3530 u64 logic_end; 3b080b2564287b Wang Shilong 2014-04-01 3531 u64 physical_end; 179313bb55be37 Qu Wenruo 2022-01-07 3532 u64 increment; /* The logical increment after finishing one stripe */ 179313bb55be37 Qu Wenruo 2022-01-07 3533 u64 offset; /* Offset inside the chunk */ 5a6ac9eacb4914 Miao Xie 2014-11-06 3534 u64 stripe_logical; 5a6ac9eacb4914 Miao Xie 2014-11-06 3535 u64 stripe_end; 3b080b2564287b Wang Shilong 2014-04-01 3536 int stop_loop = 0; 53b381b3abeb86 David Woodhouse 2013-01-29 3537 a2de733c78fa7a Arne Jansen 2011-03-08 3538 path = btrfs_alloc_path(); a2de733c78fa7a Arne Jansen 2011-03-08 3539 if (!path) a2de733c78fa7a Arne Jansen 2011-03-08 3540 return -ENOMEM; a2de733c78fa7a Arne Jansen 2011-03-08 3541 b5d67f64f9bc65 Stefan Behrens 2012-03-27 3542 /* 179313bb55be37 Qu Wenruo 2022-01-07 3543 * Work on commit root. The related disk blocks are static as b5d67f64f9bc65 Stefan Behrens 2012-03-27 3544 * long as COW is applied. This means, it is save to rewrite b5d67f64f9bc65 Stefan Behrens 2012-03-27 3545 * them to repair disk errors without any race conditions b5d67f64f9bc65 Stefan Behrens 2012-03-27 3546 */ a2de733c78fa7a Arne Jansen 2011-03-08 3547 path->search_commit_root = 1; a2de733c78fa7a Arne Jansen 2011-03-08 3548 path->skip_locking = 1; 889fc56fa40f9d Qu Wenruo 2021-12-14 3549 path->reada = READA_FORWARD; a2de733c78fa7a Arne Jansen 2011-03-08 3550 d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3551 wait_event(sctx->list_wait, b6bfebc13218f1 Stefan Behrens 2012-11-02 3552 atomic_read(&sctx->bios_in_flight) == 0); cb7ab02156e4ba Wang Shilong 2013-12-04 3553 scrub_blocked_if_needed(fs_info); a2de733c78fa7a Arne Jansen 2011-03-08 3554 179313bb55be37 Qu Wenruo 2022-01-07 3555 root = btrfs_extent_root(fs_info, bg->start); 179313bb55be37 Qu Wenruo 2022-01-07 3556 csum_root = btrfs_csum_root(fs_info, bg->start); fc28b25e1f4286 Josef Bacik 2021-11-05 3557 a2de733c78fa7a Arne Jansen 2011-03-08 3558 /* 179313bb55be37 Qu Wenruo 2022-01-07 3559 * Collect all data csums for the stripe to avoid seeking during a2de733c78fa7a Arne Jansen 2011-03-08 3560 * the scrub. This might currently (crc32) end up to be about 1MB a2de733c78fa7a Arne Jansen 2011-03-08 3561 */ e7786c3ae517b2 Arne Jansen 2011-05-28 3562 blk_start_plug(&plug); a2de733c78fa7a Arne Jansen 2011-03-08 3563 de17addce7a20d Naohiro Aota 2021-02-04 3564 if (sctx->is_dev_replace && 179313bb55be37 Qu Wenruo 2022-01-07 3565 btrfs_dev_is_sequential(sctx->wr_tgtdev, 179313bb55be37 Qu Wenruo 2022-01-07 3566 map->stripes[stripe_index].physical)) { de17addce7a20d Naohiro Aota 2021-02-04 3567 mutex_lock(&sctx->wr_lock); 179313bb55be37 Qu Wenruo 2022-01-07 3568 sctx->write_pointer = map->stripes[stripe_index].physical; de17addce7a20d Naohiro Aota 2021-02-04 3569 mutex_unlock(&sctx->wr_lock); de17addce7a20d Naohiro Aota 2021-02-04 3570 sctx->flush_all_writes = true; de17addce7a20d Naohiro Aota 2021-02-04 3571 } de17addce7a20d Naohiro Aota 2021-02-04 3572 f8636fcdd5f4ab Qu Wenruo 2022-01-07 3573 /* f8636fcdd5f4ab Qu Wenruo 2022-01-07 3574 * There used to be a big double loop to handle all profiles using the f8636fcdd5f4ab Qu Wenruo 2022-01-07 3575 * same routine, which grows larger and more gross over time. f8636fcdd5f4ab Qu Wenruo 2022-01-07 3576 * f8636fcdd5f4ab Qu Wenruo 2022-01-07 3577 * So here we handle each profile differently, so simpler profiles f8636fcdd5f4ab Qu Wenruo 2022-01-07 3578 * have simpler scrubing function. f8636fcdd5f4ab Qu Wenruo 2022-01-07 3579 */ f8636fcdd5f4ab Qu Wenruo 2022-01-07 3580 if (!(profile & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10 | f8636fcdd5f4ab Qu Wenruo 2022-01-07 3581 BTRFS_BLOCK_GROUP_RAID56_MASK))) { f8636fcdd5f4ab Qu Wenruo 2022-01-07 3582 /* f8636fcdd5f4ab Qu Wenruo 2022-01-07 3583 * Above check rules out all complex profile, the remaining f8636fcdd5f4ab Qu Wenruo 2022-01-07 3584 * profiles are SINGLE|DUP|RAID1|RAID1C*, which is simple f8636fcdd5f4ab Qu Wenruo 2022-01-07 3585 * mirrored duplication without stripe. f8636fcdd5f4ab Qu Wenruo 2022-01-07 3586 * f8636fcdd5f4ab Qu Wenruo 2022-01-07 3587 * Only @phsyical and @mirror_num needs to calculated using f8636fcdd5f4ab Qu Wenruo 2022-01-07 3588 * @stripe_index. f8636fcdd5f4ab Qu Wenruo 2022-01-07 3589 */ f8636fcdd5f4ab Qu Wenruo 2022-01-07 3590 ret = scrub_simple_mirror(sctx, root, csum_root, bg, map, f8636fcdd5f4ab Qu Wenruo 2022-01-07 3591 bg->start, bg->length, scrub_dev, f8636fcdd5f4ab Qu Wenruo 2022-01-07 3592 map->stripes[stripe_index].physical, f8636fcdd5f4ab Qu Wenruo 2022-01-07 3593 stripe_index + 1); f8636fcdd5f4ab Qu Wenruo 2022-01-07 3594 goto out; f8636fcdd5f4ab Qu Wenruo 2022-01-07 3595 } 38e821991b4eb7 Qu Wenruo 2022-01-07 3596 if (profile & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10)) { 38e821991b4eb7 Qu Wenruo 2022-01-07 3597 ret = scrub_simple_stripe(sctx, root, csum_root, bg, map, 38e821991b4eb7 Qu Wenruo 2022-01-07 3598 scrub_dev, stripe_index); 38e821991b4eb7 Qu Wenruo 2022-01-07 3599 goto out; 38e821991b4eb7 Qu Wenruo 2022-01-07 3600 } 38e821991b4eb7 Qu Wenruo 2022-01-07 3601 38e821991b4eb7 Qu Wenruo 2022-01-07 3602 /* Only RAID56 goes through the old code */ 38e821991b4eb7 Qu Wenruo 2022-01-07 3603 ASSERT(map->type & BTRFS_BLOCK_GROUP_RAID56_MASK); 179313bb55be37 Qu Wenruo 2022-01-07 3604 179313bb55be37 Qu Wenruo 2022-01-07 3605 physical = map->stripes[stripe_index].physical; 179313bb55be37 Qu Wenruo 2022-01-07 3606 offset = 0; 179313bb55be37 Qu Wenruo 2022-01-07 3607 nstripes = div64_u64(dev_extent_len, map->stripe_len); 179313bb55be37 Qu Wenruo 2022-01-07 3608 get_raid56_logic_offset(physical, stripe_index, map, &offset, NULL); 179313bb55be37 Qu Wenruo 2022-01-07 3609 increment = map->stripe_len * nr_data_stripes(map); 179313bb55be37 Qu Wenruo 2022-01-07 3610 179313bb55be37 Qu Wenruo 2022-01-07 3611 logical = chunk_logical + offset; 179313bb55be37 Qu Wenruo 2022-01-07 3612 physical_end = physical + nstripes * map->stripe_len; 179313bb55be37 Qu Wenruo 2022-01-07 3613 get_raid56_logic_offset(physical_end, stripe_index, map, &logic_end, 179313bb55be37 Qu Wenruo 2022-01-07 3614 NULL); 179313bb55be37 Qu Wenruo 2022-01-07 3615 logic_end += chunk_logical; 179313bb55be37 Qu Wenruo 2022-01-07 3616 a2de733c78fa7a Arne Jansen 2011-03-08 3617 ret = 0; a2de733c78fa7a Arne Jansen 2011-03-08 3618 /* 179313bb55be37 Qu Wenruo 2022-01-07 3619 * Due to the rotation, for RAID56 it's better to iterate each stripe 179313bb55be37 Qu Wenruo 2022-01-07 3620 * using their physical offset. a2de733c78fa7a Arne Jansen 2011-03-08 3621 */ 179313bb55be37 Qu Wenruo 2022-01-07 3622 while (physical < physical_end) { 179313bb55be37 Qu Wenruo 2022-01-07 3623 ret = get_raid56_logic_offset(physical, stripe_index, map, 179313bb55be37 Qu Wenruo 2022-01-07 3624 &logical, &stripe_logical); 471a5e456ff42e Qu Wenruo 2021-12-15 3625 logical += chunk_logical; f2f66a2f886383 Zhao Lei 2015-07-21 3626 if (ret) { 179313bb55be37 Qu Wenruo 2022-01-07 3627 /* It is parity strip */ 471a5e456ff42e Qu Wenruo 2021-12-15 3628 stripe_logical += chunk_logical; a0dd59de3c73fb Zhao Lei 2015-07-21 3629 stripe_end = stripe_logical + increment; f2f66a2f886383 Zhao Lei 2015-07-21 3630 ret = scrub_raid56_parity(sctx, map, scrub_dev, 69765031000981 Qu Wenruo 2021-12-14 3631 stripe_logical, f2f66a2f886383 Zhao Lei 2015-07-21 3632 stripe_end); f2f66a2f886383 Zhao Lei 2015-07-21 3633 if (ret) f2f66a2f886383 Zhao Lei 2015-07-21 3634 goto out; a2de733c78fa7a Arne Jansen 2011-03-08 3635 goto next; a2de733c78fa7a Arne Jansen 2011-03-08 3636 } a2de733c78fa7a Arne Jansen 2011-03-08 3637 a2de733c78fa7a Arne Jansen 2011-03-08 3638 /* 179313bb55be37 Qu Wenruo 2022-01-07 3639 * Now we're at data stripes, scrub each extents in the range. 179313bb55be37 Qu Wenruo 2022-01-07 3640 * 179313bb55be37 Qu Wenruo 2022-01-07 3641 * At this stage, if we ignore the repair part, each data stripe 179313bb55be37 Qu Wenruo 2022-01-07 3642 * is no different than SINGLE profile. 179313bb55be37 Qu Wenruo 2022-01-07 3643 * We can reuse scrub_simple_mirror() here, as the repair part 179313bb55be37 Qu Wenruo 2022-01-07 3644 * is still based on @mirror_num. 3b080b2564287b Wang Shilong 2014-04-01 3645 */ 179313bb55be37 Qu Wenruo 2022-01-07 3646 ret = scrub_simple_mirror(sctx, root, csum_root, bg, map, 179313bb55be37 Qu Wenruo 2022-01-07 3647 logical, map->stripe_len, 179313bb55be37 Qu Wenruo 2022-01-07 3648 scrub_dev, physical, 1); 179313bb55be37 Qu Wenruo 2022-01-07 3649 if (ret < 0) 5a6ac9eacb4914 Miao Xie 2014-11-06 3650 goto out; a2de733c78fa7a Arne Jansen 2011-03-08 3651 next: a2de733c78fa7a Arne Jansen 2011-03-08 3652 logical += increment; a2de733c78fa7a Arne Jansen 2011-03-08 3653 physical += map->stripe_len; d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3654 spin_lock(&sctx->stat_lock); 625f1c8dc66d77 Liu Bo 2013-04-27 3655 if (stop_loop) 471a5e456ff42e Qu Wenruo 2021-12-15 3656 sctx->stat.last_physical = map->stripes[stripe_index].physical + 471a5e456ff42e Qu Wenruo 2021-12-15 3657 dev_extent_len; 625f1c8dc66d77 Liu Bo 2013-04-27 3658 else d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3659 sctx->stat.last_physical = physical; d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3660 spin_unlock(&sctx->stat_lock); 625f1c8dc66d77 Liu Bo 2013-04-27 3661 if (stop_loop) 625f1c8dc66d77 Liu Bo 2013-04-27 3662 break; a2de733c78fa7a Arne Jansen 2011-03-08 3663 } ff023aac31198e Stefan Behrens 2012-11-06 3664 out: a2de733c78fa7a Arne Jansen 2011-03-08 3665 /* push queued extents */ d9d181c1ba7aa0 Stefan Behrens 2012-11-02 3666 scrub_submit(sctx); 3fb99303c64e31 David Sterba 2017-05-16 3667 mutex_lock(&sctx->wr_lock); ff023aac31198e Stefan Behrens 2012-11-06 3668 scrub_wr_submit(sctx); 3fb99303c64e31 David Sterba 2017-05-16 3669 mutex_unlock(&sctx->wr_lock); a2de733c78fa7a Arne Jansen 2011-03-08 3670 e7786c3ae517b2 Arne Jansen 2011-05-28 3671 blk_finish_plug(&plug); a2de733c78fa7a Arne Jansen 2011-03-08 3672 btrfs_free_path(path); 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3673 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3674 if (sctx->is_dev_replace && ret >= 0) { 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3675 int ret2; 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3676 471a5e456ff42e Qu Wenruo 2021-12-15 3677 ret2 = sync_write_pointer_for_zoned(sctx, 471a5e456ff42e Qu Wenruo 2021-12-15 @3678 chunk_logical + offset, 471a5e456ff42e Qu Wenruo 2021-12-15 3679 map->stripes[stripe_index].physical, 7db1c5d14dcd52 Naohiro Aota 2021-02-04 @3680 physical_end); 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3681 if (ret2) 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3682 ret = ret2; 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3683 } 7db1c5d14dcd52 Naohiro Aota 2021-02-04 3684 a2de733c78fa7a Arne Jansen 2011-03-08 3685 return ret < 0 ? ret : 0; a2de733c78fa7a Arne Jansen 2011-03-08 3686 } a2de733c78fa7a Arne Jansen 2011-03-08 3687 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected] _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
