From patchwork Fri Sep 7 14:18:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1422861 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 BADB23FC85 for ; Fri, 7 Sep 2012 14:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760760Ab2IGOXB (ORCPT ); Fri, 7 Sep 2012 10:23:01 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:33402 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760734Ab2IGOS7 (ORCPT ); Fri, 7 Sep 2012 10:18:59 -0400 Received: by ggdk6 with SMTP id k6so539998ggd.19 for ; Fri, 07 Sep 2012 07:18:59 -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=O3Ugw/Y9599ebPqMlf6bt35HfFjbE9MvA4D/DD6Fn+c=; b=dhcjEZEQ81ysmh10BQ+BXNZ4CfPsUmmomiRw9C8QhjPlRud/bD4CTbhpEE4SHZ+AFo /ur3nIp+QV+dif/8h1+DQ4amwAvOf3Yfem9290/ca7osfPXOR/gOPCMtsys2agcePLOW AhnECzGmKFm5B8BXucX6+3rYKDSKqoFi1ctb3lLJ6X8q5iHYhV8tBGvIyCqiKjKrtIPZ /1iVaWtbb/CYGBz3babQ7Odm9IJnLO5NV5A+Elrj2LNPluZK9Zzv09HhPwGlT+z8vol4 hi5JT1VmW8F16fIC4HWDJd2DZjatijGBwaSpQOszdU6/Fbyl0nbWWzXmKm+U9tIV3ayX GcAQ== Received: by 10.58.23.202 with SMTP id o10mr7871243vef.57.1347027539003; Fri, 07 Sep 2012 07:18:59 -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.57 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:18:58 -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 15/20] vfs: have chdir retry lookup and call once on ESTALE error Date: Fri, 7 Sep 2012 10:18:22 -0400 Message-Id: <1347027507-20956-16-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: ALoCoQlm0U4+Dhq5T3mJyq8cvFFKxrvv/ARB9qKRPqWdNL1QqKR0IoBY8Ky465+c3F3VXeoJ+5UI 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 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/open.c b/fs/open.c index a5a5c9a..81ba325 100644 --- a/fs/open.c +++ b/fs/open.c @@ -389,20 +389,21 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename) { struct path path; int error; + int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY; + unsigned int try = 0; - 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; - - set_fs_pwd(current->fs, &path); + do { + error = user_path_at(AT_FDCWD, filename, 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++)); return error; }