mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 22:42:04 +00:00
vfs: fix renameat to retry on ESTALE errors
...as always, rename is the messiest of the bunch. We have to track whether to retry or not via a separate flag since the error handling is already quite complex. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
5d18f8133c
commit
c6a9428401
15
fs/namei.c
15
fs/namei.c
@ -3840,15 +3840,17 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
|
|||||||
struct nameidata oldnd, newnd;
|
struct nameidata oldnd, newnd;
|
||||||
struct filename *from;
|
struct filename *from;
|
||||||
struct filename *to;
|
struct filename *to;
|
||||||
|
unsigned int lookup_flags = 0;
|
||||||
|
bool should_retry = false;
|
||||||
int error;
|
int error;
|
||||||
|
retry:
|
||||||
from = user_path_parent(olddfd, oldname, &oldnd, 0);
|
from = user_path_parent(olddfd, oldname, &oldnd, lookup_flags);
|
||||||
if (IS_ERR(from)) {
|
if (IS_ERR(from)) {
|
||||||
error = PTR_ERR(from);
|
error = PTR_ERR(from);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
to = user_path_parent(newdfd, newname, &newnd, 0);
|
to = user_path_parent(newdfd, newname, &newnd, lookup_flags);
|
||||||
if (IS_ERR(to)) {
|
if (IS_ERR(to)) {
|
||||||
error = PTR_ERR(to);
|
error = PTR_ERR(to);
|
||||||
goto exit1;
|
goto exit1;
|
||||||
@ -3920,11 +3922,18 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
|
|||||||
unlock_rename(new_dir, old_dir);
|
unlock_rename(new_dir, old_dir);
|
||||||
mnt_drop_write(oldnd.path.mnt);
|
mnt_drop_write(oldnd.path.mnt);
|
||||||
exit2:
|
exit2:
|
||||||
|
if (retry_estale(error, lookup_flags))
|
||||||
|
should_retry = true;
|
||||||
path_put(&newnd.path);
|
path_put(&newnd.path);
|
||||||
putname(to);
|
putname(to);
|
||||||
exit1:
|
exit1:
|
||||||
path_put(&oldnd.path);
|
path_put(&oldnd.path);
|
||||||
putname(from);
|
putname(from);
|
||||||
|
if (should_retry) {
|
||||||
|
should_retry = false;
|
||||||
|
lookup_flags |= LOOKUP_REVAL;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
exit:
|
exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user