]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
md/md-llbitmap: optimize initial sync with write_zeroes_unmap support
authorYu Kuai <yukuai@fnnas.com>
Mon, 23 Mar 2026 05:46:44 +0000 (13:46 +0800)
committerYu Kuai <yukuai@fnnas.com>
Tue, 7 Apr 2026 05:09:22 +0000 (13:09 +0800)
commite92a5325b5d3bc30730b4842249ba8990a0a92b8
treeef590e2ace2b4d7ccd8d429576e34353d34fe23a
parent4403023e2aa7bab0193121d2ec543bea862d7304
md/md-llbitmap: optimize initial sync with write_zeroes_unmap support

For RAID-456 arrays with llbitmap, if all underlying disks support
write_zeroes with unmap, issue write_zeroes to zero all disk data
regions and initialize the bitmap to BitCleanUnwritten instead of
BitUnwritten.

This optimization skips the initial XOR parity building because:
1. write_zeroes with unmap guarantees zeroed reads after the operation
2. For RAID-456, when all data is zero, parity is automatically
   consistent (0 XOR 0 XOR ... = 0)
3. BitCleanUnwritten indicates parity is valid but no user data
   has been written

The implementation adds two helper functions:
- llbitmap_all_disks_support_wzeroes_unmap(): Checks if all active
  disks support write_zeroes with unmap
- llbitmap_zero_all_disks(): Issues blkdev_issue_zeroout() to each
  rdev's data region to zero all disks

The zeroing and bitmap state setting happens in llbitmap_init_state()
during bitmap initialization. If any disk fails to zero, we fall back
to BitUnwritten and normal lazy recovery.

This significantly reduces array initialization time for RAID-456
arrays built on modern NVMe SSDs or other devices that support
write_zeroes with unmap.

Reviewed-by: Xiao Ni <xni@redhat.com>
Link: https://lore.kernel.org/linux-raid/20260323054644.3351791-4-yukuai@fnnas.com/
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
drivers/md/md-llbitmap.c