From patchwork Wed Aug 8 13:21:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1295531 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 AE57D3FCFC for ; Wed, 8 Aug 2012 13:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758529Ab2HHNWQ (ORCPT ); Wed, 8 Aug 2012 09:22:16 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:61865 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758523Ab2HHNWM (ORCPT ); Wed, 8 Aug 2012 09:22:12 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so730912yen.19 for ; Wed, 08 Aug 2012 06:22:12 -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=RTYpsByqG7mC0Djn+0L0bBkC7rgAP01yY8OQ4gLs60M=; b=oGWwefsow2D4NQHNYyt2pLgtoaGVdQ36N8LREsZdNU2bnfUY99M62KA/v8QPyfWpyx s0c3sKfcK0EDHIoHpRhacbBp3PzRbIRpiiDr5+aNl8dVK4jnJnORMYa9helbpqxeSudu /+FBHC9Hyy9ewsSXxyuP98/A+szCPnTxNdTvl2PfekIPri+MEw001h4Wm0fEAQ0ICA7C OVV8oMNz8BK0Q/sopozMFg4dVj5PhyyOlkYD4eb+0ZwnWMrMbp/WZuZpRG2BOb2fhy/d eC9k3Xmst87nVtQ1ehNTNNmGT9BynbNEEmcXMLKNEzZoWvm9NMqF7sIY+8BvFoEBXdEn 9ZXg== Received: by 10.236.76.3 with SMTP id a3mr16471797yhe.86.1344432132438; Wed, 08 Aug 2012 06:22:12 -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.22.11 (version=SSLv3 cipher=OTHER); Wed, 08 Aug 2012 06:22:11 -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 18/19] vfs: have chdir retry lookup and call once on ESTALE error Date: Wed, 8 Aug 2012 09:21:41 -0400 Message-Id: <1344432102-22312-19-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: ALoCoQlCMZc2dGzlQ2S3DrxZpfZSvZfCJSkxLD/JbmxvmicObXLnYJAeDtWwg4WjTTauBmMAAtTG 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/open.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/open.c b/fs/open.c index 147b232..59a7e9d 100644 --- a/fs/open.c +++ b/fs/open.c @@ -401,20 +401,27 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename) { struct path path; int error; + int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY; + unsigned int try = 0; + char *name; - error = user_path_dir(filename, &path); - if (error) - goto out; - - error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR); - if (error) - goto dput_and_out; + name = getname_flags(filename, lookup_flags, NULL); + if (IS_ERR(name)) + return PTR_ERR(name); - set_fs_pwd(current->fs, &path); + do { + error = kern_path_at(AT_FDCWD, name, lookup_flags, &path); + if (error) + break; -dput_and_out: - path_put(&path); -out: + error = inode_permission(path.dentry->d_inode, + MAY_EXEC | MAY_CHDIR); + if (!error) + set_fs_pwd(current->fs, &path); + path_put(&path); + lookup_flags |= LOOKUP_REVAL; + } while (retry_estale(error, try++)); + putname(name); return error; }