linux/drivers
majianpeng d206dcfa98 md/raid5: Before freeing old multi-thread worker, it should flush them.
When changing group_thread_cnt from sysfs entry, the kernel can oops.

The kernel messages are:
[  740.961389] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
[  740.961444] IP: [<ffffffff81062570>] process_one_work+0x30/0x500
[  740.961476] PGD b9013067 PUD b651e067 PMD 0
[  740.961503] Oops: 0000 [#1] SMP
[  740.961525] Modules linked in: netconsole e1000e ptp pps_core
[  740.961577] CPU: 0 PID: 3683 Comm: kworker/u8:5 Not tainted 3.12.0+ #23
[  740.961602] 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
[  740.961646] task: ffff88013abe0000 ti: ffff88013a246000 task.ti: ffff88013a246000
[  740.961673] RIP: 0010:[<ffffffff81062570>]  [<ffffffff81062570>] process_one_work+0x30/0x500
[  740.961708] RSP: 0018:ffff88013a247e08  EFLAGS: 00010086
[  740.961730] RAX: ffff8800b912b400 RBX: ffff88013a61e680 RCX: ffff8800b912b400
[  740.961757] RDX: ffff8800b912b600 RSI: ffff8800b912b600 RDI: ffff88013a61e680
[  740.961782] RBP: ffff88013a247e48 R08: ffff88013a246000 R09: 000000000002c09d
[  740.961808] R10: 000000000000010f R11: 0000000000000000 R12: ffff88013b00cc00
[  740.961833] R13: 0000000000000000 R14: ffff88013b00cf80 R15: ffff88013a61e6b0
[  740.961861] FS:  0000000000000000(0000) GS:ffff88013fc00000(0000) knlGS:0000000000000000
[  740.961893] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  740.962001] CR2: 00000000000000b8 CR3: 00000000b24fe000 CR4: 00000000000407f0
[  740.962001] Stack:
[  740.962001]  0000000000000008 ffff8800b912b600 ffff88013b00cc00 ffff88013a61e680
[  740.962001]  ffff88013b00cc00 ffff88013b00cc18 ffff88013b00cf80 ffff88013a61e6b0
[  740.962001]  ffff88013a247eb8 ffffffff810639c6 0000000000012a80 ffff88013a247fd8
[  740.962001] Call Trace:
[  740.962001]  [<ffffffff810639c6>] worker_thread+0x206/0x3f0
[  740.962001]  [<ffffffff810637c0>] ? manage_workers+0x2c0/0x2c0
[  740.962001]  [<ffffffff81069656>] kthread+0xc6/0xd0
[  740.962001]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
[  740.962001]  [<ffffffff81722ffc>] ret_from_fork+0x7c/0xb0
[  740.962001]  [<ffffffff81069590>] ? kthread_freezable_should_stop+0x70/0x70
[  740.962001] Code: 89 e5 41 57 41 56 41 55 45 31 ed 41 54 53 48 89 fb 48 83 ec 18 48 8b 06 4c 8b 67 48 48 89 c1 30 c9 a8 04 4c 0f 45 e9 80 7f 58 00 <49> 8b 45 08 44 8b b0 00 01 00 00 78 0c 41 f6 44 24 10 04 0f 84
[  740.962001] RIP  [<ffffffff81062570>] process_one_work+0x30/0x500
[  740.962001]  RSP <ffff88013a247e08>
[  740.962001] CR2: 0000000000000008
[  740.962001] ---[ end trace 39181460000748de ]---
[  740.962001] Kernel panic - not syncing: Fatal exception

This can happen if there are some stripes left, fewer than MAX_STRIPE_BATCH.
A worker is queued to handle them.
But before calling raid5_do_work, raid5d handles those
stripes making conf->active_stripe = 0.
So mddev_suspend() can return.
We might then free old worker resources before the queued
raid5_do_work() handled them.  When it runs, it crashes.

	raid5d()		raid5_store_group_thread_cnt()
	queue_work		mddev_suspend()
				handle_strips
				active_stripe=0
				free(old worker resources)
	process_one_work
	raid5_do_work

To avoid this, we should only flush the worker resources before freeing them.

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

Cc: stable@vger.kernel.org (3.12)
Fixes: b721420e87
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 Bluetooth: btusb: Add support for Belkin F8065bf 2013-09-23 17:44:25 -03:00
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 clocksource: em_sti: Set cpu_possible_mask to fix SMP broadcast 2013-09-26 02:31:04 +02:00
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 Update extcon for 3.13 2013-09-26 20:47:25 -07:00
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 sched, idle: Fix the idle polling state logic 2013-09-25 13:53:10 +02:00
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: Before freeing old multi-thread worker, it should flush them. 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 mfd: dbx500: Remove any mention of the BML8580CLK 2013-09-26 11:04:16 +02:00
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 Merge remote-tracking branch 'regulator/fix/wm8350' into regulator-linus 2013-09-30 12:04:33 +01:00
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 drivers: phy: add generic PHY framework 2013-09-27 17:35:41 -07:00
Makefile drivers: phy: add generic PHY framework 2013-09-27 17:35:41 -07:00