Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#253 closed defect (invalid)

Use of samba and open_file_cache, cause file locks and deleted files

Reported by: Bruce Kirkpatrick Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
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 -V: 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/

Description

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.

locking=no
share modes=no
oplocks = no
level2 oplocks = no
kernel oplocks =no

I'm receiving "Access is denied" errors in Windows or linux when attempting to overwrite the javascript (or any static) file in windows that has been accessed at least once with nginx.

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;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;

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.

Change History (1)

comment:1 by Maxim Dounin, 11 years ago

Resolution: invalid
Status: newclosed

Keeping files open on Windows is expected to prevent overwrite of files in question, this is how files work under Windows. If you use Windows and want to be able to overwrite files - it's not a good idea to use open_file_cache. Deletion problem you observe doesn't looks like nginx problem either - nginx only keeps files open and closes them later, nothing more.

Note: See TracTickets for help on using tickets.