Yufen Yu 8c24259323 md/raid1: exit sync request if MD_RECOVERY_INTR is set
We met a sync thread stuck as follows:

 raid1_sync_request+0x2c9/0xb50
 md_do_sync+0x983/0xfa0
 md_thread+0x11c/0x160
 kthread+0x111/0x130
 ret_from_fork+0x35/0x40
 0xffffffffffffffff

At the same time, there is a stuck mdadm thread (mdadm --manage
/dev/md2 --add /dev/sda). It is trying to stop the sync thread:

 kthread_stop+0x42/0xf0
 md_unregister_thread+0x3a/0x70
 md_reap_sync_thread+0x15/0x160
 action_store+0x142/0x2a0
 md_attr_store+0x6c/0xb0
 kernfs_fop_write+0x102/0x180
 __vfs_write+0x33/0x170
 vfs_write+0xad/0x1a0
 SyS_write+0x52/0xc0
 do_syscall_64+0x6e/0x190
 entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Debug tools show that the sync thread is waiting in raise_barrier(),
until raid1d() end all normal IO bios into bio_end_io_list(introduced
in commit 55ce74d4bfe1). But, raid1d() cannot end these bios if
MD_CHANGE_PENDING bit is set. It needs to get mddev->reconfig_mutex lock
and then clear the bit in md_check_recovery().
However, the lock is holding by mdadm in action_store().

Thus, there is a loop:
mdadm waiting for sync thread to stop, sync thread waiting for
raid1d() to end bios, raid1d() waiting for mdadm to release
mddev->reconfig_mutex lock and then it can end bios.

Fix this by checking MD_RECOVERY_INTR while waiting in raise_barrier(),
so that sync thread can exit while mdadm is stoping the sync thread.

Fixes: 55ce74d4bfe1 ("md/raid1: ensure device failure recorded before write request returns.")
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Shaohua Li <shli@fb.com>
2018-04-09 08:41:16 -07:00
..
2018-04-06 18:31:06 -07:00
2018-04-06 18:31:06 -07:00
2018-04-05 21:29:35 -07:00
2018-04-05 21:29:35 -07:00
2018-04-04 20:07:20 -07:00
2018-04-06 19:21:41 -07:00
2018-03-27 09:51:22 +02:00
2018-03-19 14:18:22 -05:00
2018-04-05 21:03:42 -07:00
2018-03-28 13:24:56 +02:00
2018-03-27 15:57:19 +02:00
2018-04-04 20:07:20 -07:00
2018-04-05 14:27:02 -07:00
2018-04-04 18:56:27 -07:00
2018-04-07 12:08:19 -07:00
2018-03-19 14:20:24 -05:00
2018-04-07 12:08:19 -07:00
2018-04-05 14:27:02 -07:00
2018-04-06 12:15:41 -07:00
2018-04-05 14:27:02 -07:00
2018-04-05 14:27:02 -07:00
2018-04-04 20:07:20 -07:00
2018-04-06 18:31:06 -07:00
2018-04-04 20:07:20 -07:00
2018-04-07 12:08:19 -07:00
2018-04-05 21:29:35 -07:00
2018-04-05 21:21:08 -07:00
2018-04-05 21:21:08 -07:00
2018-04-05 21:21:08 -07:00
2018-04-05 14:27:02 -07:00
2018-04-05 15:05:53 -07:00
2018-04-05 21:29:35 -07:00
2018-04-03 12:06:21 -07:00
2018-04-05 14:27:02 -07:00
2018-04-06 19:44:27 -07:00
2018-04-06 19:21:41 -07:00
2018-03-29 13:38:10 +03:00