vfs: have do_sys_truncate retry once on an ESTALE error
authorJeff Layton <jlayton@redhat.com>
Tue, 11 Dec 2012 17:10:11 +0000 (12:10 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 20 Dec 2012 23:50:05 +0000 (18:50 -0500)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/open.c

index c819bbdab47f6c358838eb276dd902b3cb262780..07449b911a4dcb28fecc96ed9eb2c7db14eba797 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -115,17 +115,23 @@ EXPORT_SYMBOL_GPL(vfs_truncate);
 
 static long do_sys_truncate(const char __user *pathname, loff_t length)
 {
+       unsigned int lookup_flags = LOOKUP_FOLLOW;
        struct path path;
        int error;
 
        if (length < 0) /* sorry, but loff_t says... */
                return -EINVAL;
 
-       error = user_path(pathname, &path);
+retry:
+       error = user_path_at(AT_FDCWD, pathname, lookup_flags, &path);
        if (!error) {
                error = vfs_truncate(&path, length);
                path_put(&path);
        }
+       if (retry_estale(error, lookup_flags)) {
+               lookup_flags |= LOOKUP_REVAL;
+               goto retry;
+       }
        return error;
 }