From patchwork Thu Jul 26 11:55:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1242071 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 09527DFFBF for ; Thu, 26 Jul 2012 11:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752552Ab2GZLzt (ORCPT ); Thu, 26 Jul 2012 07:55:49 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:53878 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752539Ab2GZLzp (ORCPT ); Thu, 26 Jul 2012 07:55:45 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so1845569ghr.19 for ; Thu, 26 Jul 2012 04:55:44 -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=WuLi7IgX3WR8INjhudlh05olcLkh74Yh2CFpUMe6jus=; b=LMjBf2sUMlw8l0hOQqKtTpruB6yI49e5m21cRWbH+pL/C60sQo2peRxJqN9fz0imYu N6ZYXnmcOdZqgZs009PktXFyBJxgKBMdNEUFoaTVdpkjq/2Z8MK4KA+7ZFq2sErzlikd 8ya5Yptbm5+gsC73NSW7A/eatqBG2aSHHmOFJ08uSGd+ACZ2ypWVGaobriVfVVfmYT9M e2vq5jg3M+0Gj/yIuNIR3q3qyFgZ433kClozHWKbq28yBjJRerQdwgP/USIZAYrQ9YO5 gcMFwrLbXvhuL9Lle6NuW/WmEcnFfeJoxdPPom/K2Jbwqn+mi83yohccbB2cKrIagOPl mQxw== Received: by 10.236.193.105 with SMTP id j69mr27534075yhn.21.1343303744663; Thu, 26 Jul 2012 04:55:44 -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.43 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:55:44 -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 12/17] vfs: make rmdir retry on ESTALE errors Date: Thu, 26 Jul 2012 07:55:15 -0400 Message-Id: <1343303720-11199-13-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: ALoCoQlNLu2vJx5MUc9rOBeE9ALARJf2Hj0cWdVhR9ML0r+6jdaKzqZIP/Nq6E0F4fcQyR5Odm4i Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Jeff Layton --- fs/namei.c | 82 +++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index defb210..09427f2 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3152,52 +3152,62 @@ out: static long do_rmdir(int dfd, const char __user *pathname) { int error = 0; - char * name; + char *name; struct dentry *dentry; struct nameidata nd; + unsigned int try = 0; + unsigned int lookup_flags = LOOKUP_PARENT; - error = user_path_parent(dfd, pathname, &nd, &name); - if (error) - return error; + name = getname(pathname); + if (IS_ERR(name)) + return PTR_ERR(name); - switch(nd.last_type) { - case LAST_DOTDOT: - error = -ENOTEMPTY; - goto exit1; - case LAST_DOT: - error = -EINVAL; - goto exit1; - case LAST_ROOT: - error = -EBUSY; - goto exit1; - } + do { + error = do_path_lookup(dfd, name, lookup_flags, &nd); + if (error) + break; - nd.flags &= ~LOOKUP_PARENT; + switch (nd.last_type) { + case LAST_DOTDOT: + error = -ENOTEMPTY; + goto exit1; + case LAST_DOT: + error = -EINVAL; + goto exit1; + case LAST_ROOT: + error = -EBUSY; + goto exit1; + } - mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); - dentry = lookup_hash(&nd); - error = PTR_ERR(dentry); - if (IS_ERR(dentry)) - goto exit2; - if (!dentry->d_inode) { - error = -ENOENT; - goto exit3; - } - error = mnt_want_write(nd.path.mnt); - if (error) - goto exit3; - error = security_path_rmdir(&nd.path, dentry); - if (error) - goto exit4; - error = vfs_rmdir(nd.path.dentry->d_inode, dentry); + nd.flags &= ~LOOKUP_PARENT; + + mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, + I_MUTEX_PARENT); + dentry = lookup_hash(&nd); + error = PTR_ERR(dentry); + if (IS_ERR(dentry)) + goto exit2; + if (!dentry->d_inode) { + error = -ENOENT; + goto exit3; + } + error = mnt_want_write(nd.path.mnt); + if (error) + goto exit3; + error = security_path_rmdir(&nd.path, dentry); + if (error) + goto exit4; + error = vfs_rmdir(nd.path.dentry->d_inode, dentry); exit4: - mnt_drop_write(nd.path.mnt); + mnt_drop_write(nd.path.mnt); exit3: - dput(dentry); + dput(dentry); exit2: - mutex_unlock(&nd.path.dentry->d_inode->i_mutex); + mutex_unlock(&nd.path.dentry->d_inode->i_mutex); exit1: - path_put(&nd.path); + path_put(&nd.path); + lookup_flags |= LOOKUP_REVAL; + } while (retry_estale(error, try++)); putname(name); return error; }