Re: [PATCH] btrfs: don't take dev_replace rwsem on task already holding it
From: David Sterba
Date: Tue Sep 10 2024 - 10:51:08 EST
On Mon, Sep 09, 2024 at 12:31:23PM +0000, Johannes Thumshirn wrote:
> On 09.09.24 14:29, Filipe Manana wrote:
> >>>
> >>> So the idea I suggested was not like this.
> >>> The idea was just to not ever down_read() the semaphore if the current
> >>> task is the replace task.
> >>
> >> So your idea is sth like the following (not yet tested):
> >
> > Yes, exactly.
>
> Thanks.
>
> >>> For my suggestion, since we will skip the locking of the semaphore,
> >>> we'll have to compare "current" with "dev_replace->replace_task"
> >>> without any locking,
> >>> but that's ok and we can use data_race() to silence KCSAN.
> >>
> >> I'll check if KCSAN actually complains about this.
> >>
> >> As for David's remark, do you prefere a pid or a task_struct to be
> >> stored in struct dev_replace?
> >
> > I'm fine with either one.
>
> Ok David, your call then. I'm fine with either one as well.
The task struct works, so please use it, thanks.