From patchwork Sat Oct 27 12:33: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: 1655401 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 A4F8DDFAC4 for ; Sat, 27 Oct 2012 12:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755299Ab2J0MeQ (ORCPT ); Sat, 27 Oct 2012 08:34:16 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:42731 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755021Ab2J0MeN (ORCPT ); Sat, 27 Oct 2012 08:34:13 -0400 Received: by mail-gh0-f174.google.com with SMTP id g15so699690ghb.19 for ; Sat, 27 Oct 2012 05:34:13 -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=hSPrt2OdtXkgxd4KtavoPMo7T86MDjmAYE1v8CleLTw=; b=nZdBOvQZ6NA5yXy2OqPrS7mWnc49Yybsgjp6FfPARv0He+AiOA2IvT42mMhOkbHY4K eZ9oB3UIMfWoyuc//YWBCnzFnUtP1RVK8sXkNclVx1aQDuLB04TW6GsRcLVpFQvZ4fAk EL78vTLqwGy8x816VorXuQ+SwiCGa2//rWy5aDX6zg/V2UK2wA6AJhg96Xo+by0gAxhw G3Zh0m7jsrRL3SsFp25F/4XGmuZaVy5awhpyWtyMrs3cajER3EDyPgpqTYr7asGacICf Ss7+qFzxrwu2ydNIKLJetQAD3wj2sOClqYmIG0j/g/nODSSRnPavcJVLpaRWUSfj3Rq1 Ac0w== Received: by 10.236.122.148 with SMTP id t20mr24717888yhh.19.1351341253447; Sat, 27 Oct 2012 05:34:13 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id f15sm4124613yhi.11.2012.10.27.05.34.11 (version=SSLv3 cipher=OTHER); Sat, 27 Oct 2012 05:34:12 -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 v8 12/32] vfs: fix renameat to retry on ESTALE errors Date: Sat, 27 Oct 2012 08:33:19 -0400 Message-Id: <1351341219-17837-13-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351341219-17837-1-git-send-email-jlayton@redhat.com> References: <1351341219-17837-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQloxVlWqayJGCNEdI3jeDpX4+zTF1h3VzVa4AFCu4nBwYENnNs08X3yrqA0V10w8UjI9D5q 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 467b9f1..27bff9b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3849,15 +3849,18 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, struct nameidata oldnd, newnd; struct filename *from; struct filename *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; @@ -3929,11 +3932,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; }