]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: scrub: factor out allocation and initialization of scrub_sector into helper
authorQu Wenruo <wqu@suse.com>
Mon, 8 Aug 2022 05:45:39 +0000 (13:45 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:55 +0000 (12:27 +0200)
commit5dd3d8e4680be763bdb34300d507a55cca0ec86e
tree0df23464095336622dce8820c7725746f81962f6
parent15b88f6d24f29fb6b24e8b92875a0ee7ba00b80e
btrfs: scrub: factor out allocation and initialization of scrub_sector into helper

The allocation and initialization is shared by 3 call sites, and we're
going to change the initialization of some members in the upcoming
patches.

So factor out the allocation and initialization of scrub_sector into a
helper, alloc_scrub_sector(), which will do the following work:

- Allocate the memory for scrub_sector

- Allocate a page for scrub_sector::page

- Initialize scrub_sector::refs to 1

- Attach the allocated scrub_sector to scrub_block
  The attachment is bidirectional, which means scrub_block::sectorv[]
  will be updated and scrub_sector::sblock will also be updated.

- Update scrub_block::sector_count and do extra sanity check on it

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