Bug 4689 - "New Folder" created twice - notify bug?
Summary: "New Folder" created twice - notify bug?
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.25a
Hardware: x86 Linux
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
Depends on:
Reported: 2007-06-12 12:57 UTC by Josh Kelley
Modified: 2007-06-18 12:04 UTC (History)
0 users

See Also:

Wireshark dump of mapping a drive and creating "New Folder" and "New Folder (2)" (532.91 KB, application/octet-stream)
2007-06-12 12:58 UTC, Josh Kelley
no flags Details
Level 10 debug log of mapping a drive and creating "New Folder" and "New Folder (2)" (501.14 KB, application/octet-stream)
2007-06-12 13:14 UTC, Josh Kelley
no flags Details
Patch (2.58 KB, patch)
2007-06-12 17:02 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Kelley 2007-06-12 12:57:10 UTC
When I use Windows Explorer to create a new folder (by right-clicking, going under New, and choosing Folder) on a network drive hosted by a Samba server, two new folders are created: "New Folder" and "New Folder (2)".

This happen usually, but not always; I think that disconnecting the network drive, reconnecting, then waiting a minute or so before creating the folder is sufficient to make it happen.

This is with a Windows XP SP2 client connected to Samba 3.0.25a running on CentOS 4.5.

From what I can tell from looking at packet dumps and debug logs, I think that Samba may be sending invalid NOTIFY responses to the server.  When the first "New Folder" is created, Samba sends two NOTIFY responses: one with the filename "New Folder" truncated, and one with NULL contents.  Wireshark and the CIFS Technical Reference seem to say that the second NOTIFY shouldn't happen at all.  After receiving the NOTIFY packets, the Windows client disconnects and reconnects (as error handling for the invalid NOTIFY?), does not request notification on the new connection, tries again to create "New Folder", is told there's a name collision, and so creates "New Folder (2)".
Comment 1 Josh Kelley 2007-06-12 12:58:25 UTC
Created attachment 2749 [details]
Wireshark dump of mapping a drive and creating "New Folder" and "New Folder (2)"
Comment 2 Josh Kelley 2007-06-12 13:14:09 UTC
Created attachment 2750 [details]
Level 10 debug log of mapping a drive and creating "New Folder" and "New Folder (2)"
Comment 3 Jeremy Allison 2007-06-12 14:41:40 UTC
I have a fix for this... give me an hour or so and I'll attach for testing.
Comment 4 Jeremy Allison 2007-06-12 17:02:46 UTC
Created attachment 2751 [details]

This will be in 3.0.25b - please test !
Comment 5 Josh Kelley 2007-06-13 12:36:39 UTC
Thank you for the fast fix.  It fixed the "New Folder (2)" error in testing, and I'll install it on our production servers tonight to make sure that it fixes the other client disconnects that we've been seeing.

A question, if you don't mind:  I checked the CIFS Technical Reference while trying to figure out this problem, and it made it sound like the MaxParameterCount field should limit the size of any notification messages, and from what I could tell from testing, it looks like Windows Server 2003 won't return a NOTIFY message with a buffer larger than MaxParameterCount.  However, it looks like this patch ignores MaxParameterCount and may return a message of any size.  Is MaxParameterCount not that important after all?
Comment 6 Jeremy Allison 2007-06-13 12:40:10 UTC
How did you test that the W2K server doesn't return a message greater than maxparametercount ? The XP client sends a maxparameter count of 32, which is obviously too small to be of use. None of our other code returning NTTrans params is restricted by maxparamcount so I align this with our existing practice.
Comment 7 Josh Kelley 2007-06-13 12:58:34 UTC
When tested against 2K3, notify data for the creation of "New Folder" is 32 bytes exactly and is included in the notify message.  Notify data for the creation of "New Folder (2)" is longer than 32 bytes, and the notify message sent when "New Folder (2)" is created is empty.

But the longer messages returned by Samba don't seem to cause any problems for the XP client, and it makes sense to match Samba's existing practice, and 2K3's behavior doesn't seem to match the CIFS Technical Reference either (the Tech Ref says to send a status of STATUS_NOTIFY_ENUM_DIR if the notify data is too large for the buffer, but 2K3 apparently just sends STATUS_SUCCESS).

So I'm not sure what all of that means, but it appears that either approach will work.  And I know relatively little about CIFS, so I could easily be missing something.  Thank you for your time.
Comment 8 Josh Kelley 2007-06-18 09:41:49 UTC
A quick update:  We've been running this patch for several days now on our production servers and have seen no further issues.  Thank you for the fix!
Comment 9 Jeremy Allison 2007-06-18 12:04:50 UTC
Fixed for 3.0.25b.