Bug #3514
Spurious errors setting up new SMB client sessions
0%
Description
When the smb server has multiple threads asking for a session to the AD server,
those threads will often ask at nearly the same time for the new session. This
was seen to expose a race in the SMB client session setup path that causes
one of the threads to get a spurious error (EEXIST).
Updated by Gordon Ross about 8 years ago
The way connection setup works in our SMB client is best explained by looking at:
http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libsmbfs/smb/ctx.c#1227
A new client (a) asks the driver if we already have a connection to this server,
if not, it (b) makes a door call to the smbiod asking to create one, then (c)
checks in the drive a second time, expecting that the connection now exists.
This issue describes a problem where two threads do the above nearly at
the same time, so both attempt step (b). Only the first caller doing (b)
can succeed. While the first caller is doing the connection setup, any
additional callers that fail in (b) simply because they're not first (which
they know by the EEXIST error) should simply proceed to step (c).
This comment (added to the code) summarizes the fix:
http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/fs.d/smbclnt/smbiod/smbiod.c#292
+ /* + * Create the driver session first, so that any subsequent + * requests for the same session will find this one and + * wait, the same as when a reconnect is triggered. + * + * There is still an inherent race here, where two callers + * both find no VC in the driver, and both come here trying + * to create the VC. In this case, we want the first one + * to actually do the VC setup, and the second to proceed + * as if the VC had been found in the driver. The second + * caller gets an EEXIST error from the ioctl in this case, + * which we therefore ignore here so that the caller will + * go ahead and look again in the driver for the new VC. + */
Updated by Gordon Ross about 8 years ago
- Subject changed from Spurious errors setting up new SMB client sessions to Spurious errors setting up new SMB client sessions
Updated by Gordon Ross about 8 years ago
- Status changed from Pending RTI to Resolved
commit fabf08ae7a95a47c3e249ee651d83d26f798bcfa Author: Gordon Ross <gwr@nexenta.com> Date: Sun Dec 16 22:14:45 2012 -0500 3514 Spurious errors setting up new SMB client sessions Reviewed by: Bayard Bell <bayard.bell@nexenta.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Approved by: Richard Lowe <richlowe@richlowe.net>