]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Suresh Jayaraman <sjayaraman@suse.de> |
2 | Subject: NFS: Handle -ESTALE error in access() | |
3 | References: 465955 | |
4 | Patch-mainline: 2.6.29-rc7 | |
5 | ||
6 | Upstream commit a71ee337b31271e701f689d544b6153b75609bc5. | |
7 | ||
8 | Hi Trond, | |
9 | ||
10 | I have been looking at a bugreport where trying to open applications on KDE | |
11 | on a NFS mounted home fails temporarily. There have been multiple reports on | |
12 | different kernel versions pointing to this common issue: | |
13 | http://bugzilla.kernel.org/show_bug.cgi?id=12557 | |
14 | https://bugs.launchpad.net/ubuntu/+source/linux/+bug/269954 | |
15 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508866.html | |
16 | ||
17 | This issue can be reproducible consistently by doing this on a NFS mounted | |
18 | home (KDE): | |
19 | 1. Open 2 xterm sessions | |
20 | 2. From one of the xterm session, do "ssh -X <remote host>" | |
21 | 3. "stat ~/.Xauthority" on the remote SSH session | |
22 | 4. Close the two xterm sessions | |
23 | 5. On the server do a "stat ~/.Xauthority" | |
24 | 6. Now on the client, try to open xterm | |
25 | This will fail. | |
26 | ||
27 | Even if the filehandle had become stale, the NFS client should invalidate | |
28 | the cache/inode and should repeat LOOKUP. Looking at the packet capture when | |
29 | the failure occurs shows that there were two subsequent ACCESS() calls with | |
30 | the same filehandle and both fails with -ESTALE error. | |
31 | ||
32 | I have tested the fix below. Now the client issue a LOOKUP after the | |
33 | ACCESS() call fails with -ESTALE. If all this makes sense to you, can you | |
34 | consider this for inclusion? | |
35 | ||
36 | If the server returns an -ESTALE error due to stale filehandle in response to | |
37 | an ACCESS() call, we need to invalidate the cache and inode so that LOOKUP() | |
38 | can be retried. Without this change, the nfs client retries ACCESS() with the | |
39 | same filehandle, fails again and could lead to temporary failure of | |
40 | applications running on nfs mounted home. | |
41 | ||
42 | Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> | |
43 | Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> | |
44 | --- | |
45 | ||
46 | fs/nfs/dir.c | 8 +++++++- | |
47 | 1 file changed, 7 insertions(+), 1 deletion(-) | |
48 | ||
49 | --- a/fs/nfs/dir.c | |
50 | +++ b/fs/nfs/dir.c | |
51 | @@ -1879,8 +1879,14 @@ static int nfs_do_access(struct inode *i | |
52 | cache.cred = cred; | |
53 | cache.jiffies = jiffies; | |
54 | status = NFS_PROTO(inode)->access(inode, &cache); | |
55 | - if (status != 0) | |
56 | + if (status != 0) { | |
57 | + if (status == -ESTALE) { | |
58 | + nfs_zap_caches(inode); | |
59 | + if (!S_ISDIR(inode->i_mode)) | |
60 | + set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); | |
61 | + } | |
62 | return status; | |
63 | + } | |
64 | nfs_access_add_cache(inode, &cache); | |
65 | out: | |
66 | if ((mask & ~cache.mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0) |