Use of samba and open_file_cache, cause file locks and deleted files
|Reported by:||Bruce Kirkpatrick||Owned by:||somebody|
|uname -a:||Linux centos.fbc.com 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux|
nginx version: nginx/1.3.8
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
TLS SNI support enabled
configure arguments: --add-module=/root/nginx_ajp_module-master/ --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --add-module=/root/ngx_devel_kit-master/ --add-module=/root/set-misc-nginx-module-master/
I don't know enough about nginx to know if this behavior is a bug or intentional.
I'm using nginx 1.3.8 inside a centos 6.3 virtualbox 4.2.4 virtual machine. The system is running the latest software available via yum update. The host OS is windows 7. The site files nginx is serving are on mounted samba partition, which is a folder on the host Windows system.
I.e., inside linux, nginx paths are referring to /home/vhosts and this is mounted from D:\vhosts\ on windows. The samba partition is mounted as root with 777 privileges. /etc/fstab looks like this, but with real ip, username, password:
hostip/vhosts /home/vhosts cifs username=username,password=SECRETPASSWORD,uid=root,gid=root,file_mode=0777,dir_mode=0777,rw,_netdev 0 0
I.e. linux/nginx reads from the windows share, and not the opposite.
in /etc/samba/smb.conf, I have tried to disable all samba locking features, but it seems to have no effect even after rebooting the virtual machine.
oplocks = no
level2 oplocks = no
kernel oplocks =no
If I run "service nginx reload", the lock is removed and I'm able to save the file. That's why I think it is nginx causing the lock.
The same problem occurs with directories. However, that may be a different issue not related to the use of samba.
I'm using samba so that I can manage the source code outside of the virtual machine.
Also note that after I run "service nginx reload", the file I'm editing is actually automatically deleted from the windows host. Very undesirable behavior.
WORKAROUND: It appears the "open_file_cache" feature is what is causing the lock and deleted files. When I set this option to open_file_cache off;, My problem is resolved.
This was the configuration that caused the locking and deleted file problems when using samba:
open_file_cache max=5000 inactive=20s;
I also don't have the locking/deleted file problem when the files are on the local filesystem.
By the way: thank you for this excellent software.