OSDN Git Service

btrfs: scrub: refactor scrub_raid56_parity()
authorQu Wenruo <wqu@suse.com>
Fri, 11 Mar 2022 07:38:47 +0000 (15:38 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:17:31 +0000 (17:17 +0200)
commit9ae53bf9097c8649ce7c49484888608fb15fdfea
tree23146c41c233d7646eeab1dbbdcda25f13dbfbf9
parent18d30ab961497f2934dad5cb502e3e377e6ae61c
btrfs: scrub: refactor scrub_raid56_parity()

Currently scrub_raid56_parity() has a large double loop, handling the
following things at the same time:

- Iterate each data stripe
- Iterate each extent item in one data stripe

Refactor this by:

- Introduce a new helper to handle data stripe iteration
  The new helper is scrub_raid56_data_stripe_for_parity(), which
  only has one while() loop handling the extent items inside the
  data stripe.

  The code is still mostly the same as the old code.

- Call cond_resched() for each extent
  Previously we only call cond_resched() under a complex if () check.
  I see no special reason to do that, and for other scrub functions,
  like scrub_simple_mirror() we're already doing the same cond_resched()
  after scrubbing one extent.

- Add more comments

Please note that, this patch is only to address the double loop, there
are incoming patches to do extra cleanup.

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