From patchwork Wed Aug 8 13:21:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1295721 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 2F65F3FCFC for ; Wed, 8 Aug 2012 13:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758516Ab2HHN0E (ORCPT ); Wed, 8 Aug 2012 09:26:04 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:58345 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758454Ab2HHNWA (ORCPT ); Wed, 8 Aug 2012 09:22:00 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so730657yen.19 for ; Wed, 08 Aug 2012 06:22:00 -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=bxGWTLszL6+e+BJAXrTxV7HQmZkZDbL0uW5tw3USUR4=; b=ZRCT6uccu5ZPc0b3LXDiTncw8boUASex/vHpRTH7vLJwoFi6WpvQIOBw3pDOuVp0Rp fFybsC4ZA5EzWucaPaEXwAQYLBMaUEF9NLTCVar35wIxmjDF+FBuUQJv22sy6fmLIRXU 1gmjBGZ08A8apSj04RIeWcnBRt6UkZK14osTFOgE/Ts1Wxowlc6oAfDrmU79BjCv/GFb D/vxIaDT98yHJQ3Xr6EtxBLqHyYgEpxT5Y+AUgKLs5bG+gRZ6CPE4EQL0cPpH6r/ieVj 8IzuQrqQedln80dH+oO2cpEmzLh0B+5nvLhpPxsjhYPn+5nfQdx7yAGjiLXe3nfbcd4A /kbw== Received: by 10.236.176.71 with SMTP id a47mr271500yhm.43.1344432120411; Wed, 08 Aug 2012 06:22:00 -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 l1sm24418002yhm.19.2012.08.08.06.21.59 (version=SSLv3 cipher=OTHER); Wed, 08 Aug 2012 06:21:59 -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 v5 09/19] vfs: fix mkdir to retry on ESTALE errors Date: Wed, 8 Aug 2012 09:21:32 -0400 Message-Id: <1344432102-22312-10-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344432102-22312-1-git-send-email-jlayton@redhat.com> References: <1344432102-22312-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQn/uJiKVwpuNwYtGDyD1NTm7ecbeq403xNrJCBhKr76bT7wNORIp1XZmlje9NDfCxw0wpbX 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 | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 0a0397f..9fd5163 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3190,17 +3190,26 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) struct dentry *dentry; struct path path; int error; + char *name; + unsigned int try = 0; - dentry = user_path_create(dfd, pathname, &path, 1); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); - - if (!IS_POSIXACL(path.dentry->d_inode)) - mode &= ~current_umask(); - error = security_path_mkdir(&path, dentry, mode); - if (!error) - error = vfs_mkdir(path.dentry->d_inode, dentry, mode); - done_path_create(&path, dentry); + name = getname(pathname); + if (IS_ERR(name)) + return PTR_ERR(name); + do { + dentry = kern_path_create(dfd, name, &path, true, try); + if (IS_ERR(dentry)) { + error = PTR_ERR(dentry); + break; + } + if (!IS_POSIXACL(path.dentry->d_inode)) + mode &= ~current_umask(); + error = security_path_mkdir(&path, dentry, mode); + if (!error) + error = vfs_mkdir(path.dentry->d_inode, dentry, mode); + done_path_create(&path, dentry); + } while (retry_estale(error, try++)); + putname(name); return error; }