PHP file_exists sometimes returns false for a file on CIFS share PHP file_exists sometimes returns false for a file on CIFS share linux linux

PHP file_exists sometimes returns false for a file on CIFS share


You can try to use the directio option to avoid doing inode data caching on files opened on this mount:

//10.1.2.3/Share /Share cifs credentials=/root/.smbcredentials/share_user,user=share_user,dirmode=0770,filemode=0660,uid=4000,gid=5000,forceuid,forcegid,noserverino,cache=none,directio 0 0


This is hardly a definitive answer to my problem, rather a summary of what I found out and what I settled with.

At the bottom of the problem lies that it is the OS who reports that the file does not exist. Running strace shows occasionally

access("/Share/11/222/333.zip", F_OK) = -1 ENOENT (No such file or directory)

for the files that do exist (and show up when listed with ls).

The Windows share host was sometimes under heavy disk load. What I did is move one of the shares to a different host so that the load is spread now between the two. Also, the general load on the system is a bit lighter lately. Whenever I get the error about file not existing, I retry the request some time later and it's no longer there.