Skip to content

btrfs: raid56: reduce unnecessary parity writes

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 1 replyIn review
  2. v13 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Cleanup the data bitmap after all the IO of the full stripe finished This is to ensure a cached rbio will not put its old dbitmap for the next one whoe uses the cache.
(only for the last patch)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: use integrated bitmaps for btrfs_raid_bio::dbitmap and finish_pbitmapfs/btrfs/raid56.c+22 -200 replies
2/3btrfs: use integrated bitmaps for scrub_parity::dbitmap and ebitmapfs/btrfs/scrub.c+13 -190 replies
3/3btrfs: only write the sectors in the vertical stripe which has data stripesfs/btrfs/raid56.c+49 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] btrfs: raid56: reduce unnecessary parity writes

[Changelog]
v2:
- Cleanup the data bitmap after all the IO of the full stripe finished This is to ensure a cached rbio will not put its old dbitmap for the next one whoe uses the cache.
(only for the last patch)

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.

This is due to the fact that we don't really check if the vertical stripe has any data (aka, range from higher level bio) for parity stripes.

The patchset will convert it to the following write pattern:

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

Disk 2  (data):     |               |               |
Disk 3  (parity):   |XX|            |               |

This is done by fully utilize btrfs_raid_bio::dbitmap which is only utilized by scrub path.

Now write path (either partial or full write) will also populate btrfs_raid_bio::dbitmap, and then only assemble sectors marked in dbitmap for submission.

The first two patches is just to make previous bitmap pointers into integrated bitmaps inside the bbtrfs_raid_bio and scrub_parity.

This saves 8 bytes for each structure.

The final patch does the most important work, by introducing a new helper, rbio_add_bio() to mark the btrfs_raid_bio::dbitmap. Then in finish_rmw() only add sectors which has bit in dbitmap marked to change the write pattern.

Qu Wenruo (3):
btrfs: use integrated bitmaps for btrfs_raid_bio::dbitmap and
finish_pbitmap
btrfs: use integrated bitmaps for scrub_parity::dbitmap and ebitmap
btrfs: only write the sectors in the vertical stripe which has data
stripes

 fs/btrfs/raid56.c | 95 +++++++++++++++++++++++++++++++++++------------
 fs/btrfs/scrub.c  | 32 +++++++---------
 2 files changed, 84 insertions(+), 43 deletions(-)
Signature · 1 line
2.36.1