From patchwork Fri Sep 7 14:18:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1423001 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9816940AB4 for ; Fri, 7 Sep 2012 14:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754846Ab2IGO0M (ORCPT ); Fri, 7 Sep 2012 10:26:12 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:62753 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755560Ab2IGOSy (ORCPT ); Fri, 7 Sep 2012 10:18:54 -0400 Received: by mail-yx0-f174.google.com with SMTP id l14so545956yen.19 for ; Fri, 07 Sep 2012 07:18:54 -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=trw6zrQXkPMzIgqqhdj79+BJvpjrf5CL9xZNWZYV9C0=; b=j/KEDpc/l/mIH3qS8E0YuAA5Mn+T8dNNGLZ+JFa7EJLdEnr64Es22MNo0+YRVinxZG CYfgHPwn8c7QpWa7hF9jaQkqda3CPA3NTLNFclcOr8K3ERllABWKKE7hMFwACAJq6BfO 8nDBrma/PblElE0HFgpW+bHyOSA/fSB8VW7PoE54Sh4eR5rxKaJ5479oImAh4LPjWDiX c4//XG0dzlMHdGRVEUGzLkQZgg4C4lraIvVUcW+MutEsQkvHu9nGGTBjNn3r2y+cdrhO DYs/YuyKUenrbaTHCh/dtHjrNzQvm+8BRUeLcX5DLRB9PJcd4eB7nApvmD2bHcGGGnFB WewQ== Received: by 10.58.144.232 with SMTP id sp8mr7928149veb.56.1347027534247; Fri, 07 Sep 2012 07:18:54 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-069-134-145-027.nc.res.rr.com. [69.134.145.27]) by mx.google.com with ESMTPS id v9sm3207113ves.8.2012.09.07.07.18.52 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:18:53 -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 v6 12/20] vfs: fix renameat to retry on ESTALE errors Date: Fri, 7 Sep 2012 10:18:19 -0400 Message-Id: <1347027507-20956-13-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1347027507-20956-1-git-send-email-jlayton@redhat.com> References: <1347027507-20956-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQlfbrPjRB2tAdoWcou+PahW9GrSowV33Z6bA3GlrAL3PSpKveeTY6mNQp8xyNAzf+MhWGy8 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 77c2b1055..010d428 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3847,15 +3847,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; @@ -3927,11 +3930,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; }