Re: [PATCH] ocfs2: fix lock inversion between ip_alloc_sem and transaction start

From: ZhengYuan Huang

Date: Tue Mar 31 2026 - 22:41:22 EST


On Wed, Apr 1, 2026 at 9:34 AM Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx> wrote:
> On 3/30/26 5:27 PM, ZhengYuan Huang wrote:
> >
> > [FIX]
> > Fix the ordering by starting the transaction before taking
> > ip_alloc_sem in ocfs2_setattr(), matching the ordering used by other
> > ocfs2 paths that need both locks.
>
> It looks more complicated.
> Most places also take ip_alloc_sem first then start transaction. And it
> seems that we can't do the changes ealily.
> e.g. ocfs2_truncate_file()
>
> Thanks,
> Joseph

You are right. I rechecked the locking more broadly and my current patch
assumed a transaction-first ordering that is not actually the common OCFS2
pattern. Paths like ocfs2_truncate_file() and ocfs2_dio_end_io_write() also
take ip_alloc_sem before starting a transaction, so changing ocfs2_setattr()
alone is not a good direction.

I’ll drop this patch and re-audit whether this report is a real deadlock or
a lockdep false positive caused by missing serialization context such as the
VFS inode lock / ocfs2 inode lock. If it turns out to be only a lockdep
modeling issue, I’ll come back with a much smaller annotation-based fix.

Thanks,
ZhengYuan Huang