Re: [PATCH] ocfs2: Keep the dentry lock inode alive until callbacks drain
From: Cen Zhang
Date: Mon Oct 19 2026 - 09:53:40 EST
Hi Joseph,
Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx> 于2026年10月19日周一 19:20写道:
>
> Commit 9f70968af3e6e ("ocfs2: Re-order iput in ocfs2_drop_dentry_lock")
> is what moved iput() above ocfs2_simple_drop_lockres() to begin with, and
> it was a deliberate move:
>
> Do this to avoid a theoretical (I haven't seen this in practice) race where
> the downconvert thread might drop the dentry lock, allowing a remote unlink
> to proceed before dropping the inode locks. This could bounce access to the
> orphan dir between nodes.
>
> With the new order the downconvert thread gives up the dentry lockres and
> only afterwards reaches iput() -> ocfs2_evict_inode() ->
> ocfs2_delete_inode(), which takes the nfs_sync lock in shared mode and
> then the inode lock exclusive.
>
> Thanks,
> Joseph
Thank you for the review and pointing out the history.
I will preserve iput() before ocfs2_simple_drop_lockres(). The stale
access is in ocfs2_get_dentry_osb(),
which obtains osb through dl_inode->i_sb after the final inode
reference may have been dropped.
For v2, I plan to store osb in the lock resource’s existing l_priv
field, use the default osb lookup, and recover
the containing dentry lock with container_of(). The mount context is
freed after DLM shutdown, so the callbacks
can obtain it without accessing the inode.
This preserves the existing inode and open lock release order. I will
send a revised patch soon.
Best regards,
Cen Zhang