Re: [PATCH] btrfs: don't take dev_replace rwsem on task already holding it

From: Johannes Thumshirn
Date: Mon Sep 09 2024 - 08:31:47 EST


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.