From patchwork Thu Jul 26 11:55:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1242181 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 761C9DFFBF for ; Thu, 26 Jul 2012 11:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673Ab2GZL4p (ORCPT ); Thu, 26 Jul 2012 07:56:45 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:55933 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549Ab2GZLzr (ORCPT ); Thu, 26 Jul 2012 07:55:47 -0400 Received: by mail-yw0-f46.google.com with SMTP id m54so1830418yhm.19 for ; Thu, 26 Jul 2012 04:55:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=K+tt0XkmVU1V14lwhl0IO1DbNYM52v0yvTQ/474M+rY=; b=a0ovFgNg3t8RyOXtSPAy5lXqEZ16N5LQSgeBos6/07ioMiPSa3QbE61uiH42VPVoZX E1yiBPY2CuwJYTxsz8SFV+ojMlUd693dKzO+JeecQZMoIMggYoyZe+NodFn2T9GS9Yxy 9GvNOlTXokMdXgX69/3rmJ+07hTF433UoixvnjyypbmzR9KWveizL2mCDRTrTni9M6Dy k+Y6wfxlBwOwF1M2MkvEczNiP/sLaw2JV7U7XdLemiyu86O3P2cfKirPbSjwxfNoOT02 3dHriIxdTcqY/qG9JYXpwIkcu1zIU+aJafEuPyDO4In1yiezj5y13GjAiE978a7t8z1M 6eeg== Received: by 10.236.110.209 with SMTP id u57mr17975532yhg.101.1343303747462; Thu, 26 Jul 2012 04:55:47 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id l12sm4436364ank.2.2012.07.26.04.55.46 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:55:46 -0700 (PDT) From: Jeff Layton To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, michael.brantley@deshaw.com, hch@infradead.org, miklos@szeredi.hu, pstaubach@exagrid.com Subject: [PATCH v4 14/17] vfs: fix renameat to retry on ESTALE errors Date: Thu, 26 Jul 2012 07:55:17 -0400 Message-Id: <1343303720-11199-15-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1343303720-11199-1-git-send-email-jlayton@redhat.com> References: <1343303720-11199-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQm8YmVHE2sGmCPfvObjn/a9zJMoCfDHqrG6VUpT2RUskrCi1uoglM5D8XokZfD12jJnpYWh Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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 | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 65e5177..7cf5e91 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3699,12 +3699,25 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, char *from; char *to; int error; + unsigned int try = 0; + bool should_retry = false; + unsigned int lookup_flags = LOOKUP_PARENT; - error = user_path_parent(olddfd, oldname, &oldnd, &from); - if (error) + from = getname(oldname); + if (IS_ERR(from)) + return PTR_ERR(from); + + to = getname(newname); + if (IS_ERR(to)) { + error = PTR_ERR(to); goto exit; + } +retry: + error = do_path_lookup(olddfd, from, lookup_flags, &oldnd); + if (error) + goto exit0; - error = user_path_parent(newdfd, newname, &newnd, &to); + error = do_path_lookup(newdfd, to, lookup_flags, &newnd); if (error) goto exit1; @@ -3773,13 +3786,21 @@ exit4: dput(old_dentry); exit3: unlock_rename(new_dir, old_dir); + if (retry_estale(error, try++)) + should_retry = true; exit2: path_put(&newnd.path); - putname(to); exit1: path_put(&oldnd.path); - putname(from); + if (should_retry) { + should_retry = false; + lookup_flags |= LOOKUP_REVAL; + goto retry; + } +exit0: + putname(to); exit: + putname(from); return error; }