From patchwork Thu Jul 26 11:55:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1242211 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 DFAE73FC5A for ; Thu, 26 Jul 2012 11:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752343Ab2GZL6Z (ORCPT ); Thu, 26 Jul 2012 07:58:25 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:38873 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481Ab2GZLzm (ORCPT ); Thu, 26 Jul 2012 07:55:42 -0400 Received: by gglu4 with SMTP id u4so1821285ggl.19 for ; Thu, 26 Jul 2012 04:55:42 -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=0yvAg6Lvff1iGMOmpoPckEWc2td9+Y45SaQh9aT4Tfc=; b=mIgd+Gi5GD5sw2KTUhdCqZaNNJwUlXtp5gCyM9thXQFTGM7H35Fm2zYN7JTFW7jD4k A6gX/v4Leh8gtf/gDmYtyS1T+EWnChaxDYugXx2hrx4IIEweJXvXVUQug4WLeA2OiADs EkfywV2UySyA6kNchIsG86tmO/D5UXC2FCItN8cbSi4QPwJLNX4fNS1XRZVKwlzduMBb 2mLv6MZ1VmbudubGjLLbngxPHiFAwj5ve6GqZ/rmhMTabN1Za4DF5rKsau6KSE9qdcDF /6klC1mal1x5BapmY7ZFnx4dd/po3nLCSwgKG4B18a+U59jpOhxEp1N4dRH2sqlq0owg M8PA== Received: by 10.236.185.201 with SMTP id u49mr26961690yhm.28.1343303741897; Thu, 26 Jul 2012 04:55:41 -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.40 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:55:41 -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 10/17] vfs: fix symlinkat to retry on ESTALE errors Date: Thu, 26 Jul 2012 07:55:13 -0400 Message-Id: <1343303720-11199-11-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: ALoCoQnf0b9naWPPeKQTKh/OvjzXpmGkLUxXCSFR/40ygXNcjlP2GLRKYqbNKMuWvPd71om8zwYe 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, 26 insertions(+), 17 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 4bec3f4..5a81c48 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3340,33 +3340,42 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname, int, newdfd, const char __user *, newname) { int error; - char *from; + char *from, *to; struct dentry *dentry; struct path path; + unsigned int try = 0; from = getname(oldname); if (IS_ERR(from)) return PTR_ERR(from); - dentry = user_path_create(newdfd, newname, &path, 0); - error = PTR_ERR(dentry); - if (IS_ERR(dentry)) - goto out_putname; + to = getname(newname); + if (IS_ERR(to)) { + putname(from); + return PTR_ERR(to); + } - error = mnt_want_write(path.mnt); - if (error) - goto out_dput; - error = security_path_symlink(&path, dentry, from); - if (error) - goto out_drop_write; - error = vfs_symlink(path.dentry->d_inode, dentry, from); + do { + dentry = kern_path_create(newdfd, to, &path, 0, try); + error = PTR_ERR(dentry); + if (IS_ERR(dentry)) + break; + + error = mnt_want_write(path.mnt); + if (error) + goto out_dput; + error = security_path_symlink(&path, dentry, from); + if (error) + goto out_drop_write; + error = vfs_symlink(path.dentry->d_inode, dentry, from); out_drop_write: - mnt_drop_write(path.mnt); + mnt_drop_write(path.mnt); out_dput: - dput(dentry); - mutex_unlock(&path.dentry->d_inode->i_mutex); - path_put(&path); -out_putname: + dput(dentry); + mutex_unlock(&path.dentry->d_inode->i_mutex); + path_put(&path); + } while (retry_estale(error, try++)); + putname(to); putname(from); return error; }