From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753592Ab2JBASK (ORCPT ); Mon, 1 Oct 2012 20:18:10 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:60923 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753344Ab2JBARw (ORCPT ); Mon, 1 Oct 2012 20:17:52 -0400 From: Jeff Layton To: viro@ZenIV.linux.org.uk Cc: eparis@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com Subject: [PATCH v7 32/49] vfs: fix renameat to retry on ESTALE errors Date: Mon, 1 Oct 2012 20:16:41 -0400 Message-Id: <1349137018-21948-33-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349137018-21948-1-git-send-email-jlayton@redhat.com> References: <1349137018-21948-1-git-send-email-jlayton@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ...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 --- fs/namei.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index f311ed1..dfdcd47 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3851,15 +3851,18 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, struct nameidata oldnd, newnd; struct getname_info *from; struct getname_info *to; + unsigned int try = 0; + bool should_retry = false; int error; - from = user_path_parent(olddfd, oldname, &oldnd, 0); +retry: + from = user_path_parent(olddfd, oldname, &oldnd, try); if (IS_ERR(from)) { error = PTR_ERR(from); goto exit; } - to = user_path_parent(newdfd, newname, &newnd, 0); + to = user_path_parent(newdfd, newname, &newnd, try); if (IS_ERR(to)) { error = PTR_ERR(to); goto exit1; @@ -3931,11 +3934,17 @@ exit3: unlock_rename(new_dir, old_dir); mnt_drop_write(oldnd.path.mnt); exit2: + if (retry_estale(error, try++)) + should_retry = true; path_put(&newnd.path); putname(to); exit1: path_put(&oldnd.path); putname(from); + if (should_retry) { + should_retry = false; + goto retry; + } exit: return error; } -- 1.7.11.4