Re: [PATCH] btrfs: relax dev_replace rwsem usage on scrub with rst
From: Johannes Thumshirn
Date: Thu Aug 15 2024 - 06:57:30 EST
On 14.08.24 16:14, Filipe Manana wrote:
>
> And, how actually does this patch fixes the double locking problem?
>
> Isn't the problem that the replace code ends calling btrfs_map_block()
> while holding a read lock on the semaphore and then btrfs_map_block()
> does a read lock on it again?
>
> I would suggest a different fix:
>
> Make the device replace code store a pointer (or pid) of to the task
> running device replace, and at btrfs_map_block() don't take the
> semaphore if "current" matches that pointer/pid.
>
> Wouldn't that work? Seems safe and simple to me.
From the first test, this seems to work. At least I don't get a lockdep
splat anymore.
I'll give it some more test time and then I'll submit the patch.
Thanks,
Johannes