Re: [PATCH] ocfs2: fix circular locking dependency in ocfs2_acquire_dquot
From: Joseph Qi
Date: Mon Jan 19 2026 - 20:42:38 EST
On 1/9/26 10:02 AM, Szymon Wilczek wrote:
> Hi Joseph,
>
> Thank you for pointing to the designed order in quota_global.c.
>
> I looked at the locking documentation. I see that
> "Acquire dquot for the first time" specifies:
> ocfs2_lock_global_qf -> start_trans
>
Ummm... When sync and release also is
ocfs2_lock_global_qf -> start_trans
> However, I believe the v2 patch is still necessary because lockdep
> detected a real circular dependency:
>
> sb_internal -> sysfile_lock_key -> ip_alloc_sem
>
> Since ocfs2_lock_global_qf takes ip_alloc_sem, and start_trans takes
> sb_internal (via sb_start_intwrite), the documented order inverts the
> chain above, creating an ABBA deadlock with freeze/dismount paths.
>
>From the report link, start_trans is called during
ocfs2_shutdown_local_alloc(), but ocfs2_disable_quotas() is fnished now.
So how it happens?
Thanks,
Joseph
> The designed order may have been correct before sb_start_intwrite
> became part of ocfs2_start_trans, but now this sequence conflicts
> with the VFS freeze mechanism.
>
> My patch ensures sb_internal is acquired before ip_alloc_sem, which
> matches the expected freeze ordering. Perhaps the documentation in
> quota_global.c should be updated to reflect this change?
>
> If you see a problem with this approach, I'm happy to adjust.
> What would you suggest?
>
> Thanks,
> Szymon