vfs: fix readlinkat to retry on ESTALE
authorJeff Layton <jlayton@redhat.com>
Tue, 11 Dec 2012 17:10:06 +0000 (12:10 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 20 Dec 2012 23:50:01 +0000 (18:50 -0500)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/stat.c

index d221995278803c20f91aa089dcc9823cc3c34da8..14f45459c83d650fb09c4069d5dd7db907a67b95 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -300,11 +300,13 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname,
        struct path path;
        int error;
        int empty = 0;
+       unsigned int lookup_flags = LOOKUP_EMPTY;
 
        if (bufsiz <= 0)
                return -EINVAL;
 
-       error = user_path_at_empty(dfd, pathname, LOOKUP_EMPTY, &path, &empty);
+retry:
+       error = user_path_at_empty(dfd, pathname, lookup_flags, &path, &empty);
        if (!error) {
                struct inode *inode = path.dentry->d_inode;
 
@@ -318,6 +320,10 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname,
                        }
                }
                path_put(&path);
+               if (retry_estale(error, lookup_flags)) {
+                       lookup_flags |= LOOKUP_REVAL;
+                       goto retry;
+               }
        }
        return error;
 }