From: Andrew Morton <akpm@linux-foundation.org>
To: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Cen Zhang <zzzccc427@gmail.com>,
mark@fasheh.com, jlbec@evilplan.org, heming.zhao@suse.com,
kees@kernel.org, kuba@kernel.org, ocfs2-devel@lists.linux.dev,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
baijiaju1990@gmail.com, jjzuming@gmail.com
Subject: Re: [PATCH v2] ocfs2/cluster: unlink socket containers before releasing resources
Date: Thu, 29 Oct 2026 23:38:24 -0700 [thread overview]
Message-ID: <20261029233824.ff69052e942cc24f4166c22e@linux-foundation.org> (raw)
In-Reply-To: <ff8d866d-f318-4722-a1ab-88db7a3fde63@linux.alibaba.com>
On Wed, 14 Oct 2026 10:17:57 +0800 Joseph Qi <joseph.qi@linux.alibaba.com> wrote:
>
>
> On 10/13/26 11:34 PM, Cen Zhang wrote:
> > A socket container's node and socket must remain alive while the
> > container is on sock_containers. The debugfs formatter reads sc_node
> > and sc_sock under o2net_debug_lock without taking their references, but
> > sc_kref_release() releases both before taking that lock to unlink the
> > container.
> >
> > With CONFIG_DEBUG_FS enabled, a synchronous sender can retain its last
> > socket-container reference after o2net_disconnect_node() has detached
> > the connection and flushed o2net_wq. The caller runs outside that
> > workqueue. After the sender removes its configfs dependency, node
> > removal can proceed without waiting for the sender's final sc_put():
> >
> > Sender (final sc_put) Configfs rmdir Debugfs reader
> > -------------------- -------------- --------------
> > o2nm_undepend_item()
> > Drop node item refs
> > o2nm_node_put()
> > [node can be freed]
> > sc_seq_show()
> > Lock debug lock
> > Read sc_node->nd_name
> > Unlock debug lock
> > sc_node = NULL
> > o2net_debug_del_sc()
> >
> > The earlier socket release has a similar window. The container is
> > still selectable while its socket has been released and sc_sock has
> > not yet been cleared:
> >
> > Sender (final sc_put) Debugfs reader
> > -------------------- --------------
> > sock_release(sc->sc_sock)
> > [socket can be freed]
> > sc_seq_show()
> > Lock debug lock
> > Read sc_sock->sk fields
> > Unlock debug lock
> > sc_sock = NULL
> > ...
> > o2net_debug_del_sc()
> >
> > Move o2net_debug_del_sc() before releasing either resource. Unlinking
> > under the existing debug lock waits for an active formatter to finish
> > and prevents later readers from selecting the container. This covers
> > both socket fields and node fields, including nd_num in the stats
> > formatter. Release the debug lock before the existing resource cleanup.
>
> sc_kref_release() never holds o2net_debug_lock, the lock is taken and
> dropped inside the helper o2net_debug_del_sc().
>
> So better to:
>
> s/ Release the debug lock before the existing resource cleanup.//
I made that edit, thanks.
prev parent reply other threads:[~2026-10-30 6:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 15:34 Cen Zhang
2026-10-14 2:17 ` Joseph Qi
2026-10-30 6:38 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029233824.ff69052e942cc24f4166c22e@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=baijiaju1990@gmail.com \
--cc=heming.zhao@suse.com \
--cc=jjzuming@gmail.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=zzzccc427@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®