Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-5.11/revert-problem-v5.10-raid-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull MD regression reverts from Mike Snitzer:
"A cascade of MD reverts occurred late in the v5.10-rcX cycle due to MD
raid10 discard optimizations having introduced potential for
corruption.

Those reverts exposed a dm-raid.c compiler warning that wasn't ever
knowingly introduced. That min_not_zero() type mismatch warning was
thought to be safely fixed simply by changing 'struct mddev' to use
'unsigned int' rather than int for chunk_sectors members in that
struct.

I proposed either using a cast local to dm-raid.c but thought changing
the type to 'unsigned int' more correct. While that may be, not enough
testing was paired with code review associated with making that
change. As such we were left exposed and the result was a report that
with v5.10 btrfs on MD RAID6 failed to mount:

https://lkml.org/lkml/2020/12/14/7

Given that report, it is justified to simply revert these offending
commits. stable@ has already taken steps to revert these for 5.10.1 -
this just makes sure mainline does so too"

* tag 'for-5.11/revert-problem-v5.10-raid-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
Revert "dm raid: fix discard limits for raid1 and raid10"
Revert "md: change mddev 'chunk_sectors' from int to unsigned"

+7 -9
+5 -7
drivers/md/dm-raid.c
··· 3730 3730 blk_limits_io_opt(limits, chunk_size_bytes * mddev_data_stripes(rs)); 3731 3731 3732 3732 /* 3733 - * RAID10 personality requires bio splitting, 3734 - * RAID0/1/4/5/6 don't and process large discard bios properly. 3733 + * RAID1 and RAID10 personalities require bio splitting, 3734 + * RAID0/4/5/6 don't and process large discard bios properly. 3735 3735 */ 3736 - if (rs_is_raid10(rs)) { 3737 - limits->discard_granularity = max(chunk_size_bytes, 3738 - limits->discard_granularity); 3739 - limits->max_discard_sectors = min_not_zero(rs->md.chunk_sectors, 3740 - limits->max_discard_sectors); 3736 + if (rs_is_raid1(rs) || rs_is_raid10(rs)) { 3737 + limits->discard_granularity = chunk_size_bytes; 3738 + limits->max_discard_sectors = rs->md.chunk_sectors; 3741 3739 } 3742 3740 } 3743 3741
+2 -2
drivers/md/md.h
··· 311 311 int external; /* metadata is 312 312 * managed externally */ 313 313 char metadata_type[17]; /* externally set*/ 314 - unsigned int chunk_sectors; 314 + int chunk_sectors; 315 315 time64_t ctime, utime; 316 316 int level, layout; 317 317 char clevel[16]; ··· 339 339 */ 340 340 sector_t reshape_position; 341 341 int delta_disks, new_level, new_layout; 342 - unsigned int new_chunk_sectors; 342 + int new_chunk_sectors; 343 343 int reshape_backwards; 344 344 345 345 struct md_thread *thread; /* management thread */