linux_dsm_epyc7002/drivers
majianpeng 60aaf93385 md/raid5: Use conf->device_lock protect changing of multi-thread resources.
When we change group_thread_cnt from sysfs entry, it can OOPS.

The kernel messages are:
[  135.299021] BUG: unable to handle kernel NULL pointer dereference at           (null)
[  135.299073] IP: [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
[  135.299107] PGD 0
[  135.299122] Oops: 0000 [#1] SMP
[  135.299144] Modules linked in: netconsole e1000e ptp pps_core
[  135.299188] CPU: 3 PID: 2225 Comm: md0_raid5 Not tainted 3.12.0+ #24
[  135.299214] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015  11/09/2011
[  135.299255] task: ffff8800b9638f80 ti: ffff8800b77a4000 task.ti: ffff8800b77a4000
[  135.299283] RIP: 0010:[<ffffffff815188ab>]  [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
[  135.299323] RSP: 0018:ffff8800b77a5c48  EFLAGS: 00010002
[  135.299344] RAX: ffff880037bb5c70 RBX: 0000000000000000 RCX: 0000000000000008
[  135.299371] RDX: ffff880037bb5cb8 RSI: 0000000000000001 RDI: ffff880037bb5c00
[  135.299398] RBP: ffff8800b77a5d08 R08: 0000000000000001 R09: 0000000000000000
[  135.299425] R10: ffff8800b77a5c98 R11: 00000000ffffffff R12: ffff880037bb5c00
[  135.299452] R13: 0000000000000000 R14: 0000000000000000 R15: ffff880037bb5c70
[  135.299479] FS:  0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000
[  135.299510] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  135.299532] CR2: 0000000000000000 CR3: 0000000001c0b000 CR4: 00000000000407e0
[  135.299559] Stack:
[  135.299570]  ffff8800b77a5c88 ffffffff8107383e ffff8800b77a5c88 ffff880037a64300
[  135.299611]  000000000000ec08 ffff880037bb5cb8 ffff8800b77a5c98 ffffffffffffffd8
[  135.299654]  000000000000ec08 ffff880037bb5c60 ffff8800b77a5c98 ffff8800b77a5c98
[  135.299696] Call Trace:
[  135.299711]  [<ffffffff8107383e>] ? __wake_up+0x4e/0x70
[  135.299733]  [<ffffffff81518f88>] raid5d+0x4c8/0x680
[  135.299756]  [<ffffffff817174ed>] ? schedule_timeout+0x15d/0x1f0
[  135.299781]  [<ffffffff81524c9f>] md_thread+0x11f/0x170
[  135.299804]  [<ffffffff81069cd0>] ? wake_up_bit+0x40/0x40
[  135.299826]  [<ffffffff81524b80>] ? md_rdev_init+0x110/0x110
[  135.299850]  [<ffffffff81069656>] kthread+0xc6/0xd0
[  135.299871]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
[  135.299899]  [<ffffffff81722ffc>] ret_from_fork+0x7c/0xb0
[  135.299923]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
[  135.299951] Code: ff ff ff 0f 84 d7 fe ff ff e9 5c fe ff ff 66 90 41 8b b4 24 d8 01 00 00 45 31 ed 85 f6 0f 8e 7b fd ff ff 49 8b 9c 24 d0 01 00 00 <48> 3b 1b 49 89 dd 0f 85 67 fd ff ff 48 8d 43 28 31 d2 eb 17 90
[  135.300005] RIP  [<ffffffff815188ab>] handle_active_stripes+0x32b/0x440
[  135.300005]  RSP <ffff8800b77a5c48>
[  135.300005] CR2: 0000000000000000
[  135.300005] ---[ end trace 504854e5bb7562ed ]---
[  135.300005] Kernel panic - not syncing: Fatal exception

This is because raid5d() can be running when the multi-thread
resources are changed via system. We see need to provide locking.

mddev->device_lock is suitable, but we cannot simple call
alloc_thread_groups under this lock as we cannot allocate memory
while holding a spinlock.
So change alloc_thread_groups() to allocate and return the data
structures, then raid5_store_group_thread_cnt() can take the lock
while updating the pointers to the data structures.

This fixes a bug introduced in 3.12 and so is suitable for the 3.12.x
stable series.

Fixes: b721420e87
Cc: stable@vger.kernel.org (3.12)
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Shaohua Li <shli@kernel.org>
2013-11-19 15:19:18 +11:00
..
accessibility
acpi Merge branch 'linus' into sched/core 2013-11-01 08:24:41 +01:00
amba
ata Merge branch 'for-3.12-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata 2013-10-22 08:21:34 +01:00
atm
auxdisplay
base devres: restore zeroing behavior of devres_alloc() 2013-10-25 05:46:27 +01:00
bcma Merge 3.12-rc6 into driver-core-next 2013-10-19 13:05:38 -07:00
block Via Paul Walmsley <paul@pwsan.com>: 2013-10-28 14:39:03 -07:00
bluetooth
bus ARM: driver updates for 3.13 2013-11-11 17:05:37 +09:00
cdrom
char Merge 3.12-rc6 into char-misc-next 2013-10-19 13:02:47 -07:00
clk ARM: SoC DT updates for 3.13 2013-11-11 17:34:56 +09:00
clocksource
connector connector: use 'size' everywhere in cn_netlink_send() 2013-10-02 16:03:50 -04:00
cpufreq ARM: SoC platform changes for 3.13 2013-11-11 16:49:45 +09:00
cpuidle cpuidle: calxeda: add support to use PSCI calls 2013-10-01 16:30:56 -05:00
crypto
dca
devfreq
dio
dma ARM: driver updates for 3.13 2013-11-11 17:05:37 +09:00
edac
eisa
extcon
firewire
firmware
fmc
gpio ARM: SoC DT updates for 3.13 2013-11-11 17:34:56 +09:00
gpu i915: fix compiler warning 2013-10-31 15:28:23 -07:00
hid Staging driver update for 3.13-rc1 2013-11-07 15:07:58 +09:00
hsi hsi: convert bus code to use dev_groups 2013-10-16 18:36:04 -07:00
hv Drivers: hv: vmbus: Fix a bug in channel rescind code 2013-10-19 19:53:46 -07:00
hwmon hwmon: (applesmc) Always read until end of data 2013-10-09 09:48:55 -07:00
hwspinlock
i2c i2c: i2c-mux-pinctrl: use deferred probe when adapter not found 2013-10-10 10:22:35 +02:00
ide ARM: SoC cleanups for 3.13 2013-11-11 16:42:43 +09:00
idle
iio iio: light: vcnl4000: Remove redundant code 2013-10-24 14:48:14 +01:00
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2013-10-27 10:16:33 -07:00
input ARM: SoC cleanups for 3.13 2013-11-11 16:42:43 +09:00
iommu x86, build, pci: Fix PCI_MSI build on !SMP 2013-10-04 10:43:34 -07:00
ipack ipack: convert bus code to use dev_groups 2013-10-16 18:40:57 -07:00
irqchip Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-11-12 10:02:59 +09:00
isdn
leds
lguest
macintosh
mailbox
md md/raid5: Use conf->device_lock protect changing of multi-thread resources. 2013-11-19 15:19:18 +11:00
media ARM: SoC cleanups for 3.13 2013-11-11 16:42:43 +09:00
memory
memstick memstick: convert bus code to use dev_groups 2013-10-16 18:40:58 -07:00
message i2o: convert bus code to use dev_groups 2013-10-16 18:40:58 -07:00
mfd
misc Driver Core / sysfs patches for 3.13-rc1 2013-11-07 11:42:15 +09:00
mmc Merge 3.12-rc6 into driver-core-next 2013-10-19 13:05:38 -07:00
mtd Driver Core / sysfs patches for 3.13-rc1 2013-11-07 11:42:15 +09:00
net Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2013-11-08 08:32:58 +09:00
nfc
ntb
nubus
of Revert "drivers: of: add initialization code for dma reserved memory" 2013-10-15 09:26:07 +01:00
oprofile
parisc
parport
pci ARM: driver updates for 3.13 2013-11-11 17:05:37 +09:00
pcmcia Driver Core / sysfs patches for 3.13-rc1 2013-11-07 11:42:15 +09:00
phy usb: patches for v3.13 2013-10-24 16:18:40 +01:00
pinctrl pinctrl: single: Fix build when not built on ARM 2013-10-18 16:43:06 -07:00
platform platform/x86: fix asus-wmi build error 2013-10-23 07:57:57 +01:00
pnp PNP: convert bus code to use dev_groups 2013-10-16 18:36:02 -07:00
power
pps
ps3
ptp
pwm
rapidio rapidio: convert bus code to use dev_groups 2013-10-16 18:36:03 -07:00
regulator
remoteproc
reset
rpmsg
rtc HID RTC: Open sensor hub open close 2013-10-01 22:06:15 +01:00
s390 s390/scm_blk: fix endless loop for requests != REQ_TYPE_FS 2013-11-06 14:32:22 +01:00
sbus
scsi Driver Core / sysfs patches for 3.13-rc1 2013-11-07 11:42:15 +09:00
sfi
sh
sn
spi Merge remote-tracking branch 'spi/fix/s3c64xx' into spi-linus 2013-10-07 14:51:59 +01:00
ssb ssb: convert bus code to use dev_groups 2013-10-16 18:36:03 -07:00
staging Staging driver update for 3.13-rc1 2013-11-07 15:07:58 +09:00
target target/pscsi: fix return value check 2013-10-25 10:42:09 -07:00
tc
thermal Merge branch 'x86_pkg_temp' of .git into for-rc 2013-10-21 11:26:45 +08:00
tty Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2013-11-08 08:24:38 +09:00
uio Char/Misc patches for 3.13-rc1 2013-11-07 09:41:06 +09:00
usb ARM: SoC DT updates for 3.13 2013-11-11 17:34:56 +09:00
uwb Driver Core / sysfs patches for 3.13-rc1 2013-11-07 11:42:15 +09:00
vfio VFIO: vfio_iommu_type1: fix bug caused by break in nested loop 2013-10-11 10:40:46 -06:00
vhost vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter 2013-10-25 11:03:34 -07:00
video Merge branch 'parisc-3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux 2013-11-11 18:15:25 +09:00
virt
virtio virtio: convert bus code to use dev_groups 2013-10-16 18:40:57 -07:00
vlynq
vme
w1 w1-gpio: Use devm_* functions 2013-10-29 16:58:18 -07:00
watchdog watchdog: sunxi: Fix section mismatch 2013-10-13 20:02:03 +02:00
xen xenbus: convert bus code to use dev_groups 2013-10-16 18:36:03 -07:00
zorro
Kconfig
Makefile