]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: scrub: use pointer array to replace sblocks_for_recheck
authorQu Wenruo <wqu@suse.com>
Mon, 8 Aug 2022 05:45:37 +0000 (13:45 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:55 +0000 (12:27 +0200)
commit1dfa500511d07ae2327780e467b56f389f3e38a1
treec87b2f5cf762d4c440965a057b9e1757873cd533
parent38622010a6de3a62cc72688348548854ed82dcf5
btrfs: scrub: use pointer array to replace sblocks_for_recheck

In function scrub_handle_errored_block(), we use @sblocks_for_recheck
pointer to hold one scrub_block for each mirror, and uses kcalloc() to
allocate an array.

But this one pointer for an array is not readable due to the member
offsets done by addition and not [].

Change this pointer to struct scrub_block *[BTRFS_MAX_MIRRORS], this
will slightly increase the stack memory usage.

Since function scrub_handle_errored_block() won't get iterative calls,
this extra cost would completely be acceptable.

And since we're here, also set sblock->refs and use scrub_block_put() to
clean them up, as later we will add extra members in scrub_block, which
needs scrub_block_put() to clean them up.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c