In which I learned to love STATUS_SHARING_VIOLATION
realrichardsharpe at gmail.com
Thu Dec 5 21:19:50 MST 2013
We are doing some interesting things where I am, because we have boxes
on either side of the cloud and are trying to make it look like they
form one large NAS.
This sometimes leads to interesting problems.
One such arose recently where a client, C1, on one side of the cloud
tried to create New folder in a folder, say A, and another client, C2,
on the other side of the cloud tried to create New folder in the same
This was causing the Explorer on client C2 to crash.
We were doing the correct thing, but we had increased the window
during which interesting things can occur.
When creating a new folder in the Explorer, it first sends a CREATE
with access mask of READ ATTRIBUTES and SHARING of SHARE ALL and
disposition of Open if it extists, else fail. If this fails with
OBJECT NOT FOUND, Explorer then does a CREATE with an access mask
asking for lots of WRITE things and SHARING NONE and a disposition of
create if it does not exist, else fail.
Because of the latency of the cloud, it becomes possible where both
clients can discover that the folder does not exist, and both try to
create it. One gets OBJECT NAME COLLISION (which is exactly what my
smbtorture test shows Windows returns in that situation.) However, it
seems that Microsoft have never seen this situation and Explorer gets
confused and crashes on the client that gets OBJECT_NAME_COLLISION.
As a joke I suggested to the guy looking at this that he should try to
return SHARING_VIOLATION, and lo and behold, it worked. Explorer no
longer crashes on either client and the correct things happen. C2 goes
on to create New folder (2) and everyone is happy.
This is the power of SHARING_VIOLATION.
More information about the samba-technical