From patchwork Fri Dec 14 22:55:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 1881281 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 633973FC64 for ; Fri, 14 Dec 2012 22:55:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932173Ab2LNWzj (ORCPT ); Fri, 14 Dec 2012 17:55:39 -0500 Received: from mx12.netapp.com ([216.240.18.77]:6615 "EHLO mx12.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932395Ab2LNWzj (ORCPT ); Fri, 14 Dec 2012 17:55:39 -0500 X-IronPort-AV: E=Sophos;i="4.84,284,1355126400"; d="scan'208";a="684987" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx12-out.netapp.com with ESMTP; 14 Dec 2012 14:55:38 -0800 Received: from lade.trondhjem.org.com ([10.63.238.147]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id qBEMtb1L000305; Fri, 14 Dec 2012 14:55:38 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: nfs_lookup_revalidate should not trust an inode with i_nlink == 0 Date: Fri, 14 Dec 2012 17:55:33 -0500 Message-Id: <1355525733-53242-1-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the inode has no links, then we should force a new lookup. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a46a746..d8e58ed 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -978,10 +978,11 @@ static int nfs_is_exclusive_create(struct inode *dir, unsigned int flags) * particular file and the "nocto" mount flag is not set. * */ -static inline +static int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags) { struct nfs_server *server = NFS_SERVER(inode); + int ret; if (IS_AUTOMOUNT(inode)) return 0; @@ -992,9 +993,13 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags) if ((flags & LOOKUP_OPEN) && !(server->flags & NFS_MOUNT_NOCTO) && (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) goto out_force; - return 0; +out: + return (inode->i_nlink == 0) ? -ENOENT : 0; out_force: - return __nfs_revalidate_inode(server, inode); + ret = __nfs_revalidate_inode(server, inode); + if (ret != 0) + return ret; + goto out; } /*