Re: [PATCH v5 04/14] md: don't register sync_thread for reshape directly

From: Xiao Ni
Date: Wed Feb 28 2024 - 07:57:44 EST


On Wed, Feb 28, 2024 at 8:44 PM Yu Kuai <yukuai1@xxxxxxxxxxxxxxx> wrote:
>
> Hi,
>
> 在 2024/02/28 20:07, Xiao Ni 写道:
> > I have a question here. Is it the reason sync_thread can't run
> > md_do_sync because kthread_should_stop, so it doesn't have the chance to
> > set MD_RECOVERY_DONE? Why creating sync thread in md_check_recovery
> > doesn't have this problem? Could you explain more about this?
>
> raid10_run() only register sync_thread, without calling
> md_wakeup_thread() to set the bit 'THREAD_WAKEUP', md_do_sync() will not
> be executed.

I c. The user is responsible to wake up the thread. If raid10 wakes up
the thread in the right way, we don't need to move register reshape
thread to md_check_recovery, right?

>
> raid5 defines 'pers->start' hence md_start() will call
> md_wakeup_thread().
>
> md_start_sync() will always call md_wakeup_thread() hence there is no
> such problem.
>
> BTW, this patch fix the same problem as you mentioned in your other
> thread:
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 2266358d8074..54790261254d 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -4904,6 +4904,7 @@ static void stop_sync_thread(struct mddev *mddev,
> bool locked, bool check_seq)
> * never happen
> */
> md_wakeup_thread_directly(mddev->sync_thread);
> + md_wakeup_thread(mddev->sync_thread);
> if (work_pending(&mddev->sync_work))
> flush_work(&mddev->sync_work);

The first patch of my patch set has this already. Maybe it's the
reason that my patch01 can fix this similar problem.

>
> However, I think the one to register sync_thread is responsible to wake
> it up.

Agree, the user that registers thread should wake it up. So start/stop
sync thread apis are common. And they can be called by many users.

Best Regards
Xiao
>
> Thanks,
> Kuai
>