Samba, CIFS and Deleting Files

So I’ve got a Samba share located on server A. I have that share mounted to two other servers, B and C. The idea is that B and C need to write temporary files to a single location so that multiple background processing jobs (also running on B and C) have access to the same pool of files.

When the background processes are complete they delete the file they were working on. When I do a directory listing of the share after a file has been deleted the original files names are now along the lines of cifs79, cifs78 etc. They take up the same amount of space as the original file so I assume they are the originals, just renamed.

The problem is these files don’t go away unless I restart samba (which I don’t plan on ever doing). Am I missing a simple config param that will delete files immediately?

I created my shares with this command:

mount -t cifs //10.251.251.251/uploads ./uploads -o username=samba_user,noexec

The files go into the share as -rw------- and remain that way after they change names.

Now, if I manually create a file from the box that has the share mounted, I can create, edit, delete no problem. If I start an IRB (interactive ruby) session, I can use Ruby to create/delete files no problem. It seems to be the app itself (Rails 2.3.3) which creates the file with strange permissions. But, the app and my IRB session are running as the same user, so they should have the same permissions to do whatever, no?

When I create a file on the command line or from IRB the permissions are set -rw-rw-rw-

Here’s the full smb.conf file and the output of smbstatus at the bottom: http://gist.github.com/172474

Thanks for any help!

Answer

There is, probably, a sharing/locking problem on your files. The background process is temparing the files while they are still written to by whoever is creating them.

remove the:

locking = no

from your smb.conf file. It should solve the problem. This parameter should be used only on read only shares. Like cd. Make sure that all acess to those files is through samba share. If you access them directly from the os or from nfs share. Then read this carefully.

Attribution
Source : Link , Question Author : Community , Answer Author : Igal Serban

Leave a Comment