Mailinglist Archive: opensuse-bugs (4760 mails)

< Previous Next >
[Bug 584720] ls: cannot access /nfs/turnip/windows: Stale NFS file handle
  • From: bugzilla_noreply@xxxxxxxxxx
  • Date: Tue, 20 Apr 2010 07:07:50 +0000
  • Message-id: <20100420070750.0DEF1CC7CE@xxxxxxxxxxxxxxxxxxxxxx>

Neil Brown <nfbrown@xxxxxxxxxx> changed:

What |Removed |Added

--- Comment #4 from Neil Brown <nfbrown@xxxxxxxxxx> 2010-04-20 07:07:48 UTC ---
I can duplicate something that is at least a lot like this.

If the name you give to "ls -l" includes any path components that
are in the NFS filesystem the you see changes immediately, if not
you don't.
So if "/mnt" is a mount point then

while true; do sleep 0.9; ls -l /mnt/foo ; done

will immediately show changes to 'foo', while
cd /mnt/foo
while true; do sleep 0.9 ; ls -l . ; done
will not.

"ls -l /mnt" acts like "ls -l ." because no part of "/mnt" is
within the mounted filesystem.

This inconsistency could certainly be seen as a bug.

NFS normally claims 'close-to-open' consistency, which means if
one process updates a file then closes it, and another process
subsequently opens the file (with the open being after the close)
then the second process will see the changes even if it is on another host.

I'm not sure if this is supposed to apply equally to directories and
it cannot apply exactly as you don't open a directory in order
to change it. However the equivalent should be that if you open
a directory to read from it after a change has been made, you should
see that change.
When opening the mount point or the current directory, NFS is never
told that the directory was opened. The first it knows about it is a
readdir request against an inode which was a mountpoint or current directory.

For other directories to does the equivalent of 'open' processing during
the lookup of the name of the directory. but these two directories
don't have names (in the same sense). So that doesn't work.

A possible solution would to revalidate the directory at the start of
readdir if f_pos is zero.
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index a1f6b44..df4f0a6 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -560,6 +560,9 @@ static int nfs_readdir(struct file *filp, void *dirent,
filldir_t filldir)
desc->entry = &my_entry;

+ if (filp->f_pos == 0)
+ /* Force attribute validity at open */
+ NFS_I(inode)->cache_validity |= NFS_INO_REVAL_PAGECACHE;
res = nfs_revalidate_mapping(inode, filp->f_mapping);
if (res < 0)
goto out;

This appears to work, but may be over-zealous.

I'll ask upstream.

This does not address the fact that you sometimes get 'stale file handle'.

I have managed to reproduce that though only once and with slightly older
kernels. I might explore that side again once this side is resolved.

Configure bugmail:
------- You are receiving this mail because: -------
You are on the CC list for the bug.

< Previous Next >
This Thread
  • No further messages