From patchwork Fri Sep 7 14:18:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1422941 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 77BAD3FC85 for ; Fri, 7 Sep 2012 14:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760719Ab2IGOS4 (ORCPT ); Fri, 7 Sep 2012 10:18:56 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:58573 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760667Ab2IGOSn (ORCPT ); Fri, 7 Sep 2012 10:18:43 -0400 Received: by ghrr11 with SMTP id r11so545847ghr.19 for ; Fri, 07 Sep 2012 07:18:43 -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=ijJ+6zaR4lJ9XRyBxE4Av0IfJEEJbB/qLTuSnUBgcQY=; b=cCS5HlGjHg8dZ33WdMiNHFqz0vXnLB8LTOHC/U8UWEHKanIsdYRiBMk39RdSbZc+cr MkTi7ii95ODnCuaWlhVFscSjQbZLfTvIVgkEFaLzpZxIv0mcgzKbqnPsMe3Krv7VfTlG K04I/YjUfDGxGim1xdKaWEuaByIJoGMGd68x1KJ2HfTR737h1XTxLNkxLBtjsXlauuQR pm533rg4ktrpvPr2yMHvVBiZz7LhQD8/R1aKei5+EuMMNZQ9xx0naAuGD3JREpo/+jDd LZ7JwokDdEj0SOJRGc15R9vty9k8fRRWsz2dRH+wU68ayW1YF1GjMdRrvoo4fRpYJQs8 hFig== Received: by 10.58.114.20 with SMTP id jc20mr8152370veb.15.1347027522869; Fri, 07 Sep 2012 07:18:42 -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.41 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:18:42 -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 05/20] vfs: fix mknodat to retry on ESTALE errors Date: Fri, 7 Sep 2012 10:18:12 -0400 Message-Id: <1347027507-20956-6-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: ALoCoQmYGsWZEpNCMl9FVM/fKZhLezEK4xtzN1Wh9qRzEvWGBpOK/dUMG5tOf7Tpgm6vA8TElW4V 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 | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index d71be0b..11fc388 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3176,34 +3176,41 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, struct dentry *dentry; struct path path; int error; + unsigned int try = 0; error = may_mknod(mode); if (error) return error; - dentry = user_path_create(dfd, filename, &path, false, false); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); + do { + dentry = user_path_create(dfd, filename, &path, false, try); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); - if (!IS_POSIXACL(path.dentry->d_inode)) - mode &= ~current_umask(); - error = security_path_mknod(&path, dentry, mode, dev); - if (error) - goto out; - switch (mode & S_IFMT) { - case 0: case S_IFREG: - error = vfs_create(path.dentry->d_inode,dentry,mode,true); + if (!IS_POSIXACL(path.dentry->d_inode)) + mode &= ~current_umask(); + error = security_path_mknod(&path, dentry, mode, dev); + if (error) + goto out; + switch (mode & S_IFMT) { + case 0: + case S_IFREG: + error = vfs_create(path.dentry->d_inode, dentry, + mode, true); break; - case S_IFCHR: case S_IFBLK: - error = vfs_mknod(path.dentry->d_inode,dentry,mode, + case S_IFCHR: + case S_IFBLK: + error = vfs_mknod(path.dentry->d_inode, dentry, mode, new_decode_dev(dev)); break; - case S_IFIFO: case S_IFSOCK: - error = vfs_mknod(path.dentry->d_inode,dentry,mode,0); - break; - } + case S_IFIFO: + case S_IFSOCK: + error = vfs_mknod(path.dentry->d_inode, dentry, + mode, 0); + } out: - done_path_create(&path, dentry); + done_path_create(&path, dentry); + } while (retry_estale(error, try++)); return error; }