From: "Henrique Carvalho" <henrique.carvalho@suse.com>
To: "Pengpeng Hou" <pengpeng@iscas.ac.cn>,
"Steve French" <sfrench@samba.org>
Cc: "Paulo Alcantara" <pc@manguebit.org>,
"Ronnie Sahlberg" <ronniesahlberg@gmail.com>,
"Shyam Prasad N" <sprasad@microsoft.com>,
"Tom Talpey" <tom@talpey.com>,
"Bharath SM" <bharathsm@microsoft.com>,
"Henrique Carvalho" <henrique.carvalho@suse.com>,
<linux-cifs@vger.kernel.org>, <samba-technical@lists.samba.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [RFC] smb: client: define async channel update serialization
Date: Wed, 22 Jul 2026 13:51:52 -0300 [thread overview]
Message-ID: <DK597PFVFKJJ.2OYNPDJX1P98C@suse.com> (raw)
In-Reply-To: <20260722041043.90682-1-pengpeng@iscas.ac.cn>
On Wed Jul 22, 2026 at 1:10 AM -03, Pengpeng Hou wrote:
> Commit 556bb341f9f2 ("smb: client: introduce multichannel async work
> during mount") moved multichannel setup out of the mount path and into
> independent work items. Mounts can share an existing session, so more than
> one worker can update the same channel array concurrently.
>
> cifs_try_adding_channels() snapshots chan_count and the number of missing
> channels under chan_lock, but drops that lock while each channel is opened.
> Two workers can therefore act on the same initial count. More importantly,
> cifs_ses_add_channel() publishes a new slot before taking session_mutex, and
> its failure path later decrements the current chan_count. If another worker
> has appended a slot in between, that rollback can remove the wrong tail.
> At the array limit, a stale worker can also index chans[chan_count] after
> another worker has filled the last slot.
>
> I considered making the mount worker use
> CIFS_SES_FLAG_SCALE_CHANNELS, but that flag is not a blocking lock. A worker
> that fails to acquire it has no retry or completion to wait on.
I have a patch that uses the delaying idea, please see: https://lore.kernel.org/linux-cifs/20260429205236.456099-2-henrique.carvalho@suse.com/
It should be rebased and tweaked, though, I have been delaying this for
a while now.
Do you have any opinion?
> In addition,
> smb2_reconnect() currently clears the flag on a shared exit path even when it
> only observed another updater owning it,
Actually this looks like a bug to me, no? Why is smb2_reconnect()
clearing a flag it did not acquire?
> and an early channel-disable path
> runs before the existing flag acquisition.
>
> Extending session_mutex around slot publication and rollback would serialize
> concurrent additions, but it does not by itself serialize the reconfigure
> decrease path. Conversely, a new mutex around all of
> smb3_update_ses_channels() needs an explicit lock order because reconnect can
> call channel removal while already holding session_mutex, whereas channel
> addition later acquires session_mutex for session setup.
>
> Would you prefer this to be fixed by coalescing mount requests onto one
> per-session work item, or by introducing a dedicated channel-update
> serialization primitive with an agreed lock order? Once that lifetime and
> locking contract is clear, I can prepare a narrow patch and keep the capacity
> check at the actual chans[] append as a final invariant.
I like the idea to put everything in the same worker so instead of
having a mchan_mount work have just an mchan_work and reschedule it from
mount / remount / reconnect.
I have started this but abandoned because I couldn't find a good enough
reason to change things. It just seemed I was moving the complexity
elsewhere without any real benefit.
--
Henrique
prev parent reply other threads:[~2026-07-22 16:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 4:10 Pengpeng Hou
2026-07-22 16:51 ` Henrique Carvalho [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=DK597PFVFKJJ.2OYNPDJX1P98C@suse.com \
--to=henrique.carvalho@suse.com \
--cc=bharathsm@microsoft.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=pengpeng@iscas.ac.cn \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.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®