[Samba] File deleted while locked

nipponunited.keithrob91 at spamgourmet.com nipponunited.keithrob91 at spamgourmet.com
Thu May 23 09:56:55 MDT 2013


Hi,

I'm running Samba 4.0.0 on a RHEL 6.4 machine and have created a simple share with all the default configuration options. I've also created an application (running on the RHEL box) that does the following:

- detects a file appearing in the share (using Inotify looking for the IN_CLOSE_WRITE event)
- open and fcntl lock the file
- do some processing
- move the file to somewhere else in the filesystem

When I use a Windows 7 machine to copy a file to the share (using explorer) my app works fine. However if I copy a file as before, but then while my app is processing the file if I copy the file to the share again, I get a dialog in Windows stating the file is locked, 'Try Again' or 'Cancel'. If I press Cancel, the dialog goes away but so does the file within the share. When my app tries to move the file it fails because it no longer exists.

Looking at the wireshark output on the Windows machine I see that a SetInfo request is made with a SMB2_FILE_DISPOSITION_INFO and 'Delete on close set', followed by a success response. I assume this is the cause of the file deletion? I have to admit to being a novice at both SMB and Samba so apologies in advance if I'm a little vague.

Is the above expected even though I have locked the file?

For further info, I disabled oplocks for my share with no change in behaviour.

Keith


More information about the samba mailing list