Commit f52f5c7
md: fix stopping sync thread
Currently sync thread is stopped from multiple contex:
- idle_sync_thread
- frozen_sync_thread
- __md_stop_writes
- md_set_readonly
- do_md_stop
And there are some problems:
1) sync_work is flushed while reconfig_mutex is grabbed, this can
deadlock because the work function will grab reconfig_mutex as well.
2) md_reap_sync_thread() can't be called directly while md_do_sync() is
not finished yet, for example, commit 130443d ("md: refactor
idle/frozen_sync_thread() to fix deadlock").
3) If MD_RECOVERY_RUNNING is not set, there is no need to stop
sync_thread at all because sync_thread must not be registered.
Factor out a helper stop_sync_thread(), so that above contex will behave
the same. Fix 1) by flushing sync_work after reconfig_mutex is released,
before waiting for sync_thread to be done; Fix 2) bt letting daemon thread
to unregister sync_thread; Fix 3) by always checking MD_RECOVERY_RUNNING
first.
Fixes: db5e653 ("md: delay choosing sync action to md_start_sync()")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20231205094215.1824240-4-yukuai1@huaweicloud.com1 parent c9f7cb5 commit f52f5c7
1 file changed
Lines changed: 37 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4840 | 4840 | | |
4841 | 4841 | | |
4842 | 4842 | | |
4843 | | - | |
| 4843 | + | |
| 4844 | + | |
| 4845 | + | |
| 4846 | + | |
| 4847 | + | |
| 4848 | + | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
| 4852 | + | |
4844 | 4853 | | |
4845 | | - | |
4846 | | - | |
| 4854 | + | |
4847 | 4855 | | |
4848 | | - | |
4849 | | - | |
| 4856 | + | |
| 4857 | + | |
4850 | 4858 | | |
4851 | | - | |
4852 | | - | |
4853 | | - | |
4854 | | - | |
4855 | 4859 | | |
4856 | | - | |
| 4860 | + | |
| 4861 | + | |
4857 | 4862 | | |
4858 | 4863 | | |
4859 | 4864 | | |
4860 | | - | |
4861 | | - | |
| 4865 | + | |
4862 | 4866 | | |
4863 | 4867 | | |
4864 | 4868 | | |
4865 | 4869 | | |
4866 | 4870 | | |
4867 | 4871 | | |
4868 | 4872 | | |
| 4873 | + | |
| 4874 | + | |
4869 | 4875 | | |
4870 | | - | |
| 4876 | + | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
4871 | 4882 | | |
4872 | 4883 | | |
4873 | 4884 | | |
4874 | 4885 | | |
4875 | | - | |
4876 | | - | |
4877 | 4886 | | |
4878 | 4887 | | |
4879 | | - | |
4880 | 4888 | | |
4881 | | - | |
4882 | | - | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
| 4892 | + | |
4883 | 4893 | | |
| 4894 | + | |
4884 | 4895 | | |
4885 | 4896 | | |
4886 | 4897 | | |
4887 | 4898 | | |
4888 | 4899 | | |
4889 | 4900 | | |
4890 | 4901 | | |
4891 | | - | |
4892 | 4902 | | |
4893 | | - | |
4894 | | - | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
4895 | 4907 | | |
| 4908 | + | |
4896 | 4909 | | |
4897 | 4910 | | |
4898 | 4911 | | |
| |||
6264 | 6277 | | |
6265 | 6278 | | |
6266 | 6279 | | |
6267 | | - | |
6268 | | - | |
6269 | | - | |
6270 | | - | |
6271 | | - | |
6272 | | - | |
6273 | | - | |
6274 | | - | |
| 6280 | + | |
6275 | 6281 | | |
6276 | 6282 | | |
6277 | 6283 | | |
| |||
6363 | 6369 | | |
6364 | 6370 | | |
6365 | 6371 | | |
6366 | | - | |
6367 | | - | |
6368 | | - | |
6369 | | - | |
6370 | | - | |
6371 | | - | |
6372 | | - | |
6373 | | - | |
6374 | 6372 | | |
6375 | | - | |
6376 | | - | |
6377 | | - | |
| 6373 | + | |
6378 | 6374 | | |
6379 | 6375 | | |
6380 | 6376 | | |
| |||
6428 | 6424 | | |
6429 | 6425 | | |
6430 | 6426 | | |
6431 | | - | |
6432 | | - | |
6433 | 6427 | | |
6434 | | - | |
6435 | | - | |
6436 | | - | |
6437 | | - | |
6438 | | - | |
6439 | | - | |
6440 | | - | |
6441 | | - | |
6442 | | - | |
6443 | | - | |
6444 | | - | |
| 6428 | + | |
6445 | 6429 | | |
6446 | 6430 | | |
6447 | 6431 | | |
| |||
0 commit comments