Skip to contentSkip to conversation

nfs cache bug (when server delete the file ,nfs client can read file also)

DISCUSSION fanchaoting 3 participants 7 messages Nov 23, 2012 – Nov 26, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,everyone. I found a big bug abount nfs cache.

when server delete the file ,nfs client can read file also.

the following is the reproduce.

ip: 192.168.0.19 nfs-client
ip: 192.168.0.20 nfs-client
ip: 192.168.0.21 nfs-server

############################################################################

/usr/bin/ssh -n 192.168.0.21 service nfs start
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.19 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.20 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.21 "rm -rf /nfsroot; mkdir -p /nfsroot"
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -au
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -i -o insecure,no_root_squash,rw,fsid=0 *:/nfsroot

/usr/bin/ssh -n 192.168.0.19 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)
/usr/bin/ssh -n 192.168.0.20 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)

/usr/bin/ssh -n 192.168.0.19 umount /nfsroot /usr/bin/ssh -n 192.168.0.20 umount /nfsroot
cmd="echo \"hello world\" > /nfsroot/tmpfile" /usr/bin/ssh -n 192.168.0.21 $cmd
/usr/bin/ssh -n 192.168.0.21 mkdir /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.21 touch /nfsroot/tmpdir/tmpdfile /usr/bin/ssh -n 192.168.0.19 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.20 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.21 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.21 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.19 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.20 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.21 rm -rf /nfsroot/tmpfile echo -e "sleep 60~~~~~~~~\n"
sleep 60

#############################################################################

last: In 192.168.0.19 I do:

#cat /nfsroot/tmpfile <--the nfs server delete the file,but nfs client can read the file
hello world

I think when the nfs server delete the file ,
the server should notice the nfs client,
but the upstream kernel does't this.

#1 lore raw

T24gRnJpLCAyMDEyLTExLTIzIGF0IDEyOjE4ICswODAwLCBmYW5jaGFvdGluZyB3cm90ZToNCj4g SGksZXZlcnlvbmUuIEkgZm91bmQgYSBiaWcgYnVnIGFib3VudCBuZnMgY2FjaGUuDQo+IA0KPiB3 aGVuIHNlcnZlciBkZWxldGUgdGhlIGZpbGUgLG5mcyBjbGllbnQgY2FuIHJlYWQgZmlsZSBhbHNv Lg0KPiANCj4gdGhlIGZvbGxvd2luZyBpcyB0aGUgcmVwcm9kdWNlLg0KPiANCj4gaXA6IDE5Mi4x NjguMC4xOSAgbmZzLWNsaWVudA0KPiBpcDogMTkyLjE2OC4wLjIwICBuZnMtY2xpZW50DQo+IGlw OiAxOTIuMTY4LjAuMjEgIG5mcy1zZXJ2ZXINCj4gDQo+ICMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMNCj4g DQo+IC91c3IvYmluL3NzaCAtbiAxOTIuMTY4LjAuMjEgc2VydmljZSBuZnMgc3RhcnQNCj4gL3Vz ci9iaW4vc3NoIC1uIDE5Mi4xNjguMC4yMSAvdXNyL3NiaW4vcnBjLmlkbWFwZA0KPiAvdX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MjIyMjIyMjIyMjIyMjIyMNCj4gDQo+IGxhc3Q6 IEluIDE5Mi4xNjguMC4xOSBJIGRvOg0KPiANCj4gI2NhdCAvbmZzcm9vdC90bXBmaWxlICAgICAg ICAgICA8LS10aGUgbmZzIHNlcnZlciBkZWxldGUgdGhlIGZpbGUsYnV0IG5mcyBjbGllbnQgY2Fu IHJlYWQgdGhlIGZpbGUNCj4gIGhlbGxvIHdvcmxkDQo+IA0KPiANCj4gSSB0aGluayAgd2hlbiB0 aGUgbmZzIHNlcnZlciBkZWxldGUgdGhlIGZpbGUgLA0KPiB0aGUgIHNlcnZlciBzaG91bGQgbm90 aWNlIHRoZSBuZnMgY2xpZW50LA0KPiBidXQgdGhlIHVwc3RyZWFtIGtlcm5lbCBkb2VzJ3QgdGhp cy4NCg0KU28gaXMgdGhpcyBhIHByb2JsZW0gd2l0aCB0aGUgY2xpZW50IG9yIHRoZSBzZXJ2ZXI/ IEluIG90aGVyIHdvcmRzLCBpZg0KeW91IHVzZSBhIGRpZmZlcmVudCBzZXJ2ZXIvY2xpZW50IGNv bWJpbmF0aW9uLCBkbyB5b3Ugc2VlIGEgZGlmZmVyZW50DQpyZXN1bHQ/DQoNCldoaWNoIGtlcm5l bHMgYXJlIHlvdSB1c2luZyBpbiB5b3VyIHRlc3RzIGZvciB0aGUgY2xpZW50IGFuZCBzZXJ2ZXI/ DQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXINCg0K TmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNvbQ0Kd3d3Lm5ldGFwcC5jb20NCg==

#2 lore raw
Quoted 51 lines · Trond
Quoted 50 lines · fanchaoting

Hi,everyone. I found a big bug abount nfs cache.

when server delete the file ,nfs client can read file also.

the following is the reproduce.

ip: 192.168.0.19 nfs-client
ip: 192.168.0.20 nfs-client
ip: 192.168.0.21 nfs-server

############################################################################

/usr/bin/ssh -n 192.168.0.21 service nfs start
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.19 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.20 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.21 "rm -rf /nfsroot; mkdir -p /nfsroot"
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -au
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -i -o insecure,no_root_squash,rw,fsid=0 *:/nfsroot

/usr/bin/ssh -n 192.168.0.19 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)
/usr/bin/ssh -n 192.168.0.20 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)

/usr/bin/ssh -n 192.168.0.19 umount /nfsroot /usr/bin/ssh -n 192.168.0.20 umount /nfsroot
cmd="echo \"hello world\" > /nfsroot/tmpfile" /usr/bin/ssh -n 192.168.0.21 $cmd
/usr/bin/ssh -n 192.168.0.21 mkdir /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.21 touch /nfsroot/tmpdir/tmpdfile /usr/bin/ssh -n 192.168.0.19 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.20 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.21 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.21 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.19 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.20 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.21 rm -rf /nfsroot/tmpfile echo -e "sleep 60~~~~~~~~\n"
sleep 60

#############################################################################

last: In 192.168.0.19 I do:

#cat /nfsroot/tmpfile <--the nfs server delete the file,but nfs client can read the file
hello world

Quoted 8 lines
Quoted 3 lines

I think when the nfs server delete the file ,
the server should notice the nfs client,
but the upstream kernel does't this.

So is this a problem with the client or the server? In other words, if you use a different server/client combination, do you see a different result?

I think that the server has the problem .when the server deletes the file , it should notice the client immediately.

Quoted 2 lines

Which kernels are you using in your tests for the client and server?

I found the problem in kernel 3.7.0-rc6

#3 lore raw

T24gRnJpLCAyMDEyLTExLTIzIGF0IDEzOjIzICswODAwLCBmYW5jaGFvdGluZyB3cm90ZToNCj4g TXlrbGVidXN0LCBUcm9uZCDlhpnpgZM6DQo+ID4gT24gRnJpLCAyMDEyLTExLTIzIGF0IDEyOjE4 ICswODAwLCBmYW5jaGFvdGluZyB3cm90ZToNCj4gPj4gSGksZXZlcnlvbmUuIEkgZm91bmQgYSBi aWcgYnVnIGFib3VudCBuZnMgY2FjaGUuDQo+ID4+DQo+ID4+IHdoZW4gc2VydmVyIGRlbGV0ZSB0 aGUgZmlsZSAsbmZzIGNsaWVudCBjYW4gcmVhZCBmaWxlIGFsc28uDQo+ID4+DQo+ID4+IHRoZSBm b2xsb3dpbmcgaXMgdGhlIHJlcHJvZHVjZS4NCj4gPj4NCj4gPj4gaXA6IDE5Mi4xNjguMC4xOSAg bmZzLWNsaWVudA0KPiA+PiBpcDogMTkyLjE2OC4wLjIwICBuZnMtY2xpZW50DQo+ID4+IGlwOiAx OTIuMTY4LjAuMjEgIG5mcy1zZXJ2ZXINCj4gPj4NCj4gPj4gIyMjIyMjIyMjIyMjIyMjIyMjIyMj IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIw0K PiA+Pg0KPiA+PiAvdXNyL2Jpbi9zc2ggLW4gMTkyLjE2OC4wLjIxIHNlcnZpY2UgbmZzIHN0YXJ0 DQo+ID4+IC91c3IvYmluL3NzaCAtbiAx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lines · fanchaoting
Quoted 58 lines · Trond
Quoted 46 lines · fanchaoting

Hi,everyone. I found a big bug abount nfs cache.

when server delete the file ,nfs client can read file also.

the following is the reproduce.

ip: 192.168.0.19 nfs-client
ip: 192.168.0.20 nfs-client
ip: 192.168.0.21 nfs-server

############################################################################

/usr/bin/ssh -n 192.168.0.21 service nfs start
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.19 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.20 /usr/sbin/rpc.idmapd
/usr/bin/ssh -n 192.168.0.21 "rm -rf /nfsroot; mkdir -p /nfsroot"
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -au
/usr/bin/ssh -n 192.168.0.21 /usr/sbin/exportfs -i -o insecure,no_root_squash,rw,fsid=0 *:/nfsroot

/usr/bin/ssh -n 192.168.0.19 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)
/usr/bin/ssh -n 192.168.0.20 test -d /nfsroot || (rm -rf /nfsroot; mkdir -p /nfsroot)

/usr/bin/ssh -n 192.168.0.19 umount /nfsroot /usr/bin/ssh -n 192.168.0.20 umount /nfsroot
cmd="echo \"hello world\" > /nfsroot/tmpfile" /usr/bin/ssh -n 192.168.0.21 $cmd
/usr/bin/ssh -n 192.168.0.21 mkdir /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.21 touch /nfsroot/tmpdir/tmpdfile /usr/bin/ssh -n 192.168.0.19 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.20 mount -t nfs4 192.168.0.21:/ /nfsroot /usr/bin/ssh -n 192.168.0.21 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.21 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.19 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile /usr/bin/ssh -n 192.168.0.20 ls -l /nfsroot/tmpdir /usr/bin/ssh -n 192.168.0.19 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.20 cat /nfsroot/tmpfile > /dev/null /usr/bin/ssh -n 192.168.0.21 rm -rf /nfsroot/tmpfile echo -e "sleep 60~~~~~~~~\n"
sleep 60

#############################################################################

last: In 192.168.0.19 I do:

Quoted 7 lines

#cat /nfsroot/tmpfile <--the nfs server delete the file,but nfs client can read the file
hello world

I think when the nfs server delete the file ,
the server should notice the nfs client,
but the upstream kernel does't this.

So is this a problem with the client or the server? In other words, if you use a different server/client combination, do you see a different result?

Quoted 8 lines
Quoted 2 lines

I think that the server has the problem .when the server deletes the file , it should notice the client immediately.

There is no notification mechanism in NFS; on open(), the client is supposed to revalidate its cached information and the server is supposed to return an ESTALE error if the filehandle is no longer valid. Either one of these 2 mechanisms (client revalidation or server reply) could be going wrong here, which is why I'm asking.

I found J. Bruce Fields's patch(break delegations on unlink) maybe solve this problem . But I did't found it in the upstream kernel.

I think when the server delete the file, it should reply a DELEGRETURN to the nfs client.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Which kernels are you using in your tests for the client and server?

I found the problem in kernel 3.7.0-rc6

OK. Do you have a non-Linux server or client available that you can use for testing? Alternatively, could you use wireshark to capture a dump of the NFS traffic between the client and server?

In the wireshark, I found the right traffic should have open operation, but now i can't find the open operation.

I found the function nfs4_open_prepare has problem , in the old kernel , it can run

...snip...

  rpc_call_start(task);

...snip...

Quoted 1 line
#5 lore raw
Quoted 14 lines · fanchaoting
Quoted 13 lines · Trond
Quoted 11 lines · fanchaoting
Quoted 8 lines · Trond
Quoted 3 lines · fanchaoting

I think when the nfs server delete the file ,
the server should notice the nfs client,
but the upstream kernel does't this.

So is this a problem with the client or the server? In other words, if you use a different server/client combination, do you see a different result?

I think that the server has the problem .when the server deletes the file , it should notice the client immediately.

Quoted 8 lines
Quoted 5 lines

There is no notification mechanism in NFS; on open(), the client is supposed to revalidate its cached information and the server is supposed to return an ESTALE error if the filehandle is no longer valid. Either one of these 2 mechanisms (client revalidation or server reply) could be going wrong here, which is why I'm asking.

I found J. Bruce Fields's patch(break delegations on unlink) maybe solve this problem . But I did't found it in the upstream kernel.

Yes, still working on getting that merged. Next step is probably to rebase it on top of jlayton's ESTALE patches, assuming those will go in first. In theory they could make 3.8 but that may be optimistic.

--b.

#6 lore raw
Quoted 19 lines · [email protected] 写道:
Quoted 18 lines · fanchaoting
Quoted 17 lines · Trond
Quoted 11 lines · fanchaoting
Quoted 8 lines · Trond
Quoted 3 lines · fanchaoting

I think when the nfs server delete the file ,
the server should notice the nfs client,
but the upstream kernel does't this.

So is this a problem with the client or the server? In other words, if you use a different server/client combination, do you see a different result?

I think that the server has the problem .when the server deletes the file , it should notice the client immediately.

There is no notification mechanism in NFS; on open(), the client is supposed to revalidate its cached information and the server is supposed to return an ESTALE error if the filehandle is no longer valid. Either one of these 2 mechanisms (client revalidation or server reply) could be going wrong here, which is why I'm asking.

Quoted 7 lines
Quoted 2 lines

I found J. Bruce Fields's patch(break delegations on unlink) maybe solve this problem . But I did't found it in the upstream kernel.

Yes, still working on getting that merged. Next step is probably to rebase it on top of jlayton's ESTALE patches, assuming those will go in first. In theory they could make 3.8 but that may be optimistic.

Yes, when I applyed the patch, this problem was solved. I found when server deleted the file , it can return "DELEGRETURN" to the nfs client.

Quoted 7 lines

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html