lkml.org 
[lkml]   [2012]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v5 11/19] vfs: fix linkat to retry on ESTALE errors
Date
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/namei.c | 60 ++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 20 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 9986117..d6e9754 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3565,6 +3565,8 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
struct path old_path, new_path;
int how = 0;
int error;
+ char *old, *new;
+ unsigned int try = 0;

if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)
return -EINVAL;
@@ -3582,30 +3584,48 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
if (flags & AT_SYMLINK_FOLLOW)
how |= LOOKUP_FOLLOW;

- error = user_path_at(olddfd, oldname, how, &old_path);
- if (error)
- return error;
+ old = getname_flags(oldname, how, NULL);
+ if (IS_ERR(old))
+ return PTR_ERR(old);

- new_dentry = user_path_create(newdfd, newname, &new_path, 0);
- error = PTR_ERR(new_dentry);
- if (IS_ERR(new_dentry))
- goto out;
+ new = getname(newname);
+ if (IS_ERR(new)) {
+ putname(old);
+ return PTR_ERR(new);
+ }

- error = -EXDEV;
- if (old_path.mnt != new_path.mnt)
- goto out_dput;
- error = may_linkat(&old_path);
- if (unlikely(error))
- goto out_dput;
- error = security_path_link(old_path.dentry, &new_path, new_dentry);
- if (error)
- goto out_dput;
- error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
+ do {
+ error = kern_path_at(olddfd, old, how, &old_path);
+ if (error)
+ break;
+
+ new_dentry = kern_path_create(newdfd, new, &new_path, 0, try);
+ error = PTR_ERR(new_dentry);
+ if (IS_ERR(new_dentry)) {
+ path_put(&old_path);
+ break;
+ }
+
+ error = -EXDEV;
+ if (old_path.mnt != new_path.mnt)
+ goto out_dput;
+ error = may_linkat(&old_path);
+ if (unlikely(error))
+ goto out_dput;
+ error = security_path_link(old_path.dentry, &new_path,
+ new_dentry);
+ if (error)
+ goto out_dput;
+ error = vfs_link(old_path.dentry, new_path.dentry->d_inode,
+ new_dentry);
out_dput:
- done_path_create(&new_path, new_dentry);
+ done_path_create(&new_path, new_dentry);
out:
- path_put(&old_path);
-
+ path_put(&old_path);
+ how |= LOOKUP_REVAL;
+ } while (retry_estale(error, try++));
+ putname(new);
+ putname(old);
return error;
}

--
1.7.11.2


\
 
 \ /
  Last update: 2012-08-08 16:03    [W:0.162 / U:1.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site