linux-stable/drivers
Jason Baron e836007089 md/raid0: add discard support for the 'original' layout
We've found that using raid0 with the 'original' layout and discard
enabled with different disk sizes (such that at least two zones are
created) can result in data corruption. This is due to the fact that
the discard handling in 'raid0_handle_discard()' assumes the 'alternate'
layout. We've seen this corruption using ext4 but other filesystems are
likely susceptible as well.

More specifically, while multiple zones are necessary to create the
corruption, the corruption may not occur with multiple zones if they
layout in such a way the layout matches what the 'alternate' layout
would have produced. Thus, not all raid0 devices with the 'original'
layout, different size disks and discard enabled will encounter this
corruption.

The 3.14 kernel inadvertently changed the raid0 disk layout for different
size disks. Thus, running a pre-3.14 kernel and post-3.14 kernel on the
same raid0 array could corrupt data. This lead to the creation of the
'original' layout (to match the pre-3.14 layout) and the 'alternate' layout
(to match the post 3.14 layout) in the 5.4 kernel time frame and an option
to tell the kernel which layout to use (since it couldn't be autodetected).
However, when the 'original' layout was added back to 5.4 discard support
for the 'original' layout was not added leading this issue.

I've been able to reliably reproduce the corruption with the following
test case:

1. create raid0 array with different size disks using original layout
2. mkfs
3. mount -o discard
4. create lots of files
5. remove 1/2 the files
6. fstrim -a (or just the mount point for the raid0 array)
7. umount
8. fsck -fn /dev/md0 (spews all sorts of corruptions)

Let's fix this by adding proper discard support to the 'original' layout.
The fix 'maps' the 'original' layout disks to the order in which they are
read/written such that we can compare the disks in the same way that the
current 'alternate' layout does. A 'disk_shift' field is added to
'struct strip_zone'. This could be computed on the fly in
raid0_handle_discard() but by adding this field, we save some computation
in the discard path.

Note we could also potentially fix this by re-ordering the disks in the
zones that follow the first one, and then always read/writing them using
the 'alternate' layout. However, that is seen as a more substantial change,
and we are attempting the least invasive fix at this time to remedy the
corruption.

I've verified the change using the reproducer mentioned above. Typically,
the corruption is seen after less than 3 iterations, while the patch has
run 500+ iterations.

Cc: NeilBrown <neilb@suse.de>
Cc: Song Liu <song@kernel.org>
Fixes: c84a1372df ("md/raid0: avoid RAID0 data corruption due to layout confusion.")
Cc: stable@vger.kernel.org
Signed-off-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230623180523.1901230-1-jbaron@akamai.com
2023-06-30 15:43:50 -07:00
..
accel accel/qaic: Call DRM helper function to destroy prime GEM 2023-06-20 08:07:29 -06:00
accessibility braille_console: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:53 -07:00
acpi Power management updates for 6.5-rc1 2023-06-26 19:36:30 -07:00
amba ARM: tegra: Remove MODULE_LICENSE in non-modules 2023-04-05 15:03:17 +02:00
android binder: fix UAF of alloc->vma in race with munmap() 2023-05-20 17:56:23 +01:00
ata ata: libata-scsi: Avoid deadlock on rescan after device resume 2023-06-18 12:00:49 +09:00
atm
auxdisplay auxdisplay: Switch i2c drivers back to use .probe() 2023-06-02 13:23:32 +02:00
base regmap: Updates for v6.5 2023-06-28 13:26:19 -07:00
bcma bcma: Add explicit of_device.h include 2023-04-14 15:32:56 +03:00
block - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
bluetooth Bluetooth: hci_qca: fix debugfs registration 2023-06-05 17:13:14 -07:00
bus modules-6.4-rc1 2023-04-27 16:36:55 -07:00
cdrom cdrom/gdrom: Fix build error 2023-06-29 08:09:31 -06:00
cdx cdx: fix build failure due to sysfs 'bus_type' argument needing to be const 2023-04-27 16:21:32 -07:00
char for-6.5/splice-2023-06-23 2023-06-26 11:52:12 -07:00
clk regulator: Updates for v6.5 2023-06-28 13:32:47 -07:00
clocksource Scheduler changes for v6.5: 2023-06-27 14:03:21 -07:00
comedi
connector
counter - New Drivers 2023-05-02 10:41:31 -07:00
cpufreq cpufreq: intel_pstate: Fix energy_performance_preference for passive 2023-06-21 19:42:58 +02:00
cpuidle cpuidle: Use local_clock_noinstr() 2023-06-05 21:11:09 +02:00
crypto workqueue: Ordered workqueue creation cleanups 2023-06-27 16:46:06 -07:00
cxl cxl: Explicitly initialize resources when media is not ready 2023-05-26 13:34:39 -07:00
dax
dca Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
devfreq PM / devfreq: mtk-cci: Fix variable deferencing before NULL check 2023-05-29 23:25:31 +09:00
dio
dma dmaengine: at_hdmac: Extend the Flow Controller bitfield to three bits 2023-05-24 11:20:28 +05:30
dma-buf udmabuf: revert 'Add support for mapping hugepages (v4)' 2023-06-19 13:19:32 -07:00
edac - Add initial support for RAS hardware found on AMD server GPUs (MI200). 2023-06-26 15:09:18 -07:00
eisa
extcon
firewire firewire: net: fix unexpected release of object for asynchronous request packet 2023-05-11 09:06:49 +09:00
firmware xen: branch for v6.5-rc1 2023-06-27 16:03:20 -07:00
fpga Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
fsi
gnss
gpio regmap: Updates for v6.5 2023-06-28 13:26:19 -07:00
gpu - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
greybus greybus: Use alloc_ordered_workqueue() to create ordered workqueues 2023-05-08 13:52:27 -10:00
hid for-linus-2023060501 2023-06-06 04:36:02 -07:00
hsi
hte Devicetree updates for v6.4, part 2: 2023-04-27 10:09:05 -07:00
hv x86/hyperv: Fix hyperv_pcpu_input_arg handling when CPUs go online/offline 2023-06-17 23:09:47 +00:00
hwmon hwmon: (k10temp) Add PCI ID for family 19, model 78h 2023-05-08 11:36:19 +02:00
hwspinlock hwspinlock: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:52 -07:00
hwtracing arm64 updates for 6.5: 2023-06-26 17:11:53 -07:00
i2c i2c: imx-lpi2c: fix type char overflow issue when calculating the clock cycle 2023-06-23 12:58:24 +02:00
i3c i3c: ast2600: set variable ast2600_i3c_ops storage-class-specifier to static 2023-04-30 23:50:26 +02:00
idle intel_idle: Add a "Long HLT" C1 state for the VM guest mode 2023-06-21 19:46:58 +02:00
iio iio: imu: inv_icm42600: fix timestamp reset 2023-05-20 17:33:14 +01:00
infiniband - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
input regulator: Updates for v6.5 2023-06-28 13:32:47 -07:00
interconnect modules-6.4-rc1 2023-04-27 16:36:55 -07:00
iommu - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
ipack
irqchip ARM updates for v6.5-rc1 2023-06-26 17:07:53 -07:00
isdn Including fixes from netfilter. 2023-05-05 19:12:01 -07:00
leds leds: qcom-lpg: Fix PWM period limits 2023-06-03 17:00:28 +02:00
macintosh powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
mailbox mailbox: mailbox-test: fix a locking issue in mbox_test_message_write() 2023-05-31 13:26:44 -05:00
mcb mcb-lpc: Reallocate memory region to avoid memory overlapping 2023-04-20 14:24:01 +02:00
md md/raid0: add discard support for the 'original' layout 2023-06-30 15:43:50 -07:00
media - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
memory ARM: SoC drivers for v6.4 2023-04-25 12:02:16 -07:00
memstick memstick r592: make memstick_debug_get_tpc_name() static 2023-06-12 15:16:19 +02:00
message Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
mfd TI TPS6594 PMIC support (RTC, pinctrl, regulators) 2023-06-07 13:39:25 +01:00
misc - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
mmc MMC core: 2023-06-28 14:06:39 -07:00
most staging: most: Replace all non-returning strlcpy with strscpy 2023-06-01 07:07:37 -07:00
mtd Core MTD changes: 2023-06-28 14:02:03 -07:00
mux
net hardening updates for v6.5-rc1 2023-06-27 21:24:18 -07:00
nfc nfc: fdp: Add MODULE_FIRMWARE macros 2023-06-18 11:19:52 +01:00
ntb
nubus nubus: Don't list slot resources by default 2023-05-22 13:51:56 +02:00
nvdimm
nvme nvme fixes for Linux 6.5 2023-06-30 14:04:08 -06:00
nvmem modules-6.4-rc1 2023-04-27 16:36:55 -07:00
of of: overlay: Fix missing of_node_put() in error case of init_overlay_changeset() 2023-06-09 16:12:37 -06:00
opp Devicetree updates for v6.4, part 2: 2023-04-27 10:09:05 -07:00
parisc parisc: Replace regular spinlock with spin_trylock on panic path 2023-05-03 17:43:26 +02:00
parport
pci - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
pcmcia
peci
perf - Arnd Bergmann has fixed a bunch of -Wmissing-prototypes in 2023-06-28 10:59:38 -07:00
phy phy: qcom-snps: correct struct qcom_snps_hsphy kerneldoc 2023-05-16 19:48:55 +05:30
pinctrl regulator: Updates for v6.5 2023-06-28 13:32:47 -07:00
platform chrome platform changes for 6.5 2023-06-26 20:12:07 -07:00
pnp
power spi-geni-qcom: Add new interfaces and utilise them 2023-06-07 13:28:09 +01:00
powercap powercap: RAPL: Fix a NULL vs IS_ERR() bug 2023-06-12 19:51:21 +02:00
pps
ps3
ptp Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
pwm docs: update some straggling Documentation/arm references 2023-06-16 08:31:47 -06:00
rapidio Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
ras ras/debugfs: Fix error checking for debugfs_create_dir() 2023-05-16 21:12:23 +02:00
regulator Add Renesas PMIC RAA215300 and built-in RTC 2023-06-24 01:57:59 +01:00
remoteproc Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
reset Nothing looks out of the ordinary in this batch of clk driver updates. There 2023-04-29 17:29:39 -07:00
rpmsg Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
rtc mfd: rk808: Split into core and i2c 2023-05-15 16:19:03 +01:00
s390 s390 updates for 6.5 merge window 2023-06-27 15:49:10 -07:00
sbus Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
scsi hardening updates for v6.5-rc1 2023-06-27 21:24:18 -07:00
sh
siox
slimbus
soc Add Renesas PMIC RAA215300 and built-in RTC 2023-06-24 01:57:59 +01:00
soundwire soundwire: stream: Add missing clear of alloc_slave_rt 2023-06-08 17:08:04 +05:30
spi spi: Updates for v6.5 2023-06-28 13:48:42 -07:00
spmi spmi: Add a check for remove callback when removing a SPMI driver 2023-04-20 14:16:39 +02:00
ssb
staging Staging driver fix for 6.4-rc7 2023-06-17 11:04:10 -07:00
target for-6.5/block-2023-06-23 2023-06-26 12:47:20 -07:00
tc
tee AMDTEE add return origin to load TA command 2023-06-07 12:58:22 +02:00
thermal Thermal control updates for 6.5-rc1 2023-06-26 19:41:26 -07:00
thunderbolt thunderbolt: Mask ring interrupt on Intel hardware as well 2023-05-31 10:37:21 +03:00
tty Move the Arm architecture documentation under Documentation/arch/. This 2023-06-27 11:58:16 -07:00
ufs scsi: ufs: core: Fix MCQ nr_hw_queues 2023-05-16 21:07:26 -04:00
uio
usb - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
vdpa - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
vfio mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
vhost - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
video fbdev: bw2: Convert to platform remove callback returning void 2023-05-30 18:33:25 +02:00
virt workqueue: Ordered workqueue creation cleanups 2023-06-27 16:46:06 -07:00
virtio - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
vlynq
w1 Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
watchdog linux-watchdog 6.4-rc1 tag 2023-05-04 18:33:56 -07:00
xen - Yosry Ahmed brought back some cgroup v1 stats in OOM logs. 2023-06-28 10:28:11 -07:00
zorro
Kconfig
Makefile