Re: [PATCH] scsi: target: Fix recursive locking in __configfs_open_file()
From: Prithvi
Date: Wed Jan 21 2026 - 12:51:46 EST
On Tue, Jan 20, 2026 at 05:48:16AM -0800, Bart Van Assche wrote:
> On 1/19/26 10:50 AM, Prithvi wrote:
> > Possible unsafe locking scenario:
> >
> > CPU0
> > ----
> > lock(&p->frag_sem);
> > lock(&p->frag_sem);
> The least intrusive way to suppress this type of lockdep complaints is
> by using lockdep_register_key() and lockdep_unregister_key().
>
> Thanks,
>
> Bart.
Hello Bart,
I tried using lockdep_register_key() and lockdep_unregister_key() for the
frag_sem lock, however it stil gives the possible recursive locking
warning. Here is the patch and the bug report from its test:
https://lore.kernel.org/all/6767d8ea.050a0220.226966.0021.GAE@xxxxxxxxxx/T/#m3203ceddf3423b7116ba9225d182771608f93a6f
Would using down_read_nested() and subclasses be a better option here?
I also checked out some documentation regarding it and learnt that to use
the _nested() form, the hierarchy among the locks should be mapped
accurately; however, IIUC, there isn't any hierarchy between the locks in
this case, is this right?
Apologies if I am missing something obvious here, and thanks for your
time and guidance.
Best Regards,
Prithvi