]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/btrfs/block-group.c
btrfs: scrub: try harder to mark RAID56 block groups read-only
authorQu Wenruo <wqu@suse.com>
Thu, 13 Apr 2023 05:57:17 +0000 (13:57 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 17 May 2023 09:59:46 +0000 (11:59 +0200)
commit7561551e7ba870b9659083b95feb520fb2dacce3
treee1038e662744c9a67c727007767bd53d88fce227
parent1d6a4fc85717677e00fefffd847a50fc5928ce69
btrfs: scrub: try harder to mark RAID56 block groups read-only

Currently we allow a block group not to be marked read-only for scrub.

But for RAID56 block groups if we require the block group to be
read-only, then we're allowed to use cached content from scrub stripe to
reduce unnecessary RAID56 reads.

So this patch would:

- Make btrfs_inc_block_group_ro() try harder
  During my tests, for cases like btrfs/061 and btrfs/064, we can hit
  ENOSPC from btrfs_inc_block_group_ro() calls during scrub.

  The reason is if we only have one single data chunk, and trying to
  scrub it, we won't have any space left for any newer data writes.

  But this check should be done by the caller, especially for scrub
  cases we only temporarily mark the chunk read-only.
  And newer data writes would always try to allocate a new data chunk
  when needed.

- Return error for scrub if we failed to mark a RAID56 chunk read-only

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