Skip to contentSkip to conversation

stat family function problem (php file_exists)

DISCUSSION larith 2 participants 2 messages Feb 24, 2011 – Feb 25, 2011

Subsystems (2)
lore
Share & tools
lore

larith

author
#0 lore raw

Hi

I have one nfs server mounted on 2 clients. If I check on client2 if a file exists, then after creating this file on client2 is is not immediately visible to file_exist() function on client2. it was only after some time. how to fix this ?

client1:/mnt/storage0/test# cat a.php
<?php
if (file_exists ($argv[1])) {
    echo "1\n";
} else {
    echo "0\n";
}
client2:/mnt/storage0/test# php a.php test1
0
client1:/mnt/storage0/test# touch test1
client2:/mnt/storage0/test# php a.php test1
0
client2:/mnt/storage0/test# php a.php test1
0
..........
client2:/mnt/storage0/test# php a.php test1
1

mtab:

xxx:/mnt/drbd0/ /mnt/storage0 nfs rw,hard,timeo=7,intr,addr=xxx 0 0

export

/mnt/drbd0 10.0.0.0/8(rw,async,no_subtree_check,no_root_squash,fsid=100)

#1 lore raw
Quoted 3 lines · larith

Hi

I have one nfs server mounted on 2 clients. If I check on client2 if a file exists, then after creating this file on client2 is is not immediately visible to file_exist() function on client2. it was only after some time. how to fix this ?

1) Use open() instead of stat()

or

2) Use the -olookupcache= mount option (see 'man 5 nfs').

Trond

Quoted 8 lines
client1:/mnt/storage0/test# cat a.php
<?php
if (file_exists ($argv[1])) {
    echo "1\n";
} else {
    echo "0\n";
}
Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com