md: remove redundant check of 'mddev->sync_thread'
authorYu Kuai <yukuai3@huawei.com>
Thu, 28 Dec 2023 12:55:51 +0000 (20:55 +0800)
committerSong Liu <song@kernel.org>
Mon, 5 Feb 2024 23:23:58 +0000 (15:23 -0800)
commit61c90765e131e63ead773b9b99167415e246a945
tree47089c3a374c58e150385f830737436b56555037
parent3bca7640b4c50621b94365a1746f4b86116fec56
md: remove redundant check of 'mddev->sync_thread'

The lifetime of sync_thread:

1) Set MD_RECOVERY_NEEDED and wake up daemon thread (by ioctl/sysfs or
   other events);
2) Daemon thread woke up, md_check_recovery() found that
   MD_RECOVERY_NEEDED is set:
   a) try to grab reconfig_mutex;
   b) set MD_RECOVERY_RUNNING;
   c) clear MD_RECOVERY_NEEDED, and then queue sync_work;
3) md_start_sync() choose sync_action, then register sync_thread;
4) md_do_sync() is done, set MD_RECOVERY_DONE and wake up daemon thread;
5) Daemon thread woke up, md_check_recovery() found that
   MD_RECOVERY_DONE is set:
   a) try to grab reconfig_mutex;
   b) unregister sync_thread;
   c) clear MD_RECOVERY_RUNNING and MD_RECOVERY_DONE;

Hence there is no such case that MD_RECOVERY_RUNNING is not set, while
sync_thread is registered.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20231228125553.2697765-2-yukuai1@huaweicloud.com
drivers/md/md.c
drivers/md/raid5.c