]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: only write the sectors in the vertical stripe which has data stripes
authorQu Wenruo <wqu@suse.com>
Sat, 20 Aug 2022 06:34:59 +0000 (14:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:18:40 +0000 (11:18 +0200)
commit17a1dea876ee570355cf69369624e8bb59be22d5
treebcddc73f8e75d2aa4ce0f5973d45e78011caf4fe
parent2e7faf1e3767d5298a551c49f63907daaa4d06c1
btrfs: only write the sectors in the vertical stripe which has data stripes

commit 1d11642b35d0cbb1cefa9decc2d07d44a88e7519 upstream.

If we have only 8K partial write at the beginning of a full RAID56
stripe, we will write the following contents:

                    0  8K           32K             64K
Disk 1 (data):     |XX|            |               |
Disk 2  (data):     |               |               |
Disk 3  (parity):   |XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|

|X| means the sector will be written back to disk.

Note that, although we won't write any sectors from disk 2, but we will
write the full 64KiB of parity to disk.

This behavior is fine for now, but not for the future (especially for
RAID56J, as we waste quite some space to journal the unused parity
stripes).

So here we will also utilize the btrfs_raid_bio::dbitmap, anytime we
queue a higher level bio into an rbio, we will update rbio::dbitmap to
indicate which vertical stripes we need to writeback.

And at finish_rmw(), we also check dbitmap to see if we need to write
any sector in the vertical stripe.

So after the patch, above example will only lead to the following
writeback pattern:

                    0  8K           32K             64K
Disk 1 (data):     |XX|            |               |
Disk 2  (data):     |               |               |
Disk 3  (parity):   |XX|            |               |

Acked-by: David Sterba <dsterba@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/raid56.c