From patchwork Thu Jun 29 13:34:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9816977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3B0D603F2 for ; Thu, 29 Jun 2017 13:35:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96C672851A for ; Thu, 29 Jun 2017 13:35:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B64828705; Thu, 29 Jun 2017 13:35:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3005428725 for ; Thu, 29 Jun 2017 13:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163AbdF2NfD (ORCPT ); Thu, 29 Jun 2017 09:35:03 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:51338 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbdF2Ne7 (ORCPT ); Thu, 29 Jun 2017 09:34:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FhIy08JV+6Z82j+9yj7H3IkH5BsLworLmnMhyHW1leQ=; b=dxXNYLtAOlIOhAORfDUsM3Hg6 zbEoccPj745WI9JfTZAZHHdJW9wbPUpqT7DWH0zPEOkB27xjuMp2ARSXHzfNf5CwoSLoxZBwtpYml d7aZhlRRarDLprWkq2rDNLLDUrl0sFLpVHFFiiP2UkteBY5eL8X3B9yJsvAFdYYjDmKaJL1GBrxdW zv2cepYA/Jl7NKaN+n7MpbQ0+vhLE1hU44dW2KFaJfVUKAvcp2Qw6+O2N175uupHvNctYA3d8D1pm mlxo/YZpZuk2qevXUWnFazmC4Id5L7L5YBtL/fEt0uiCJrKWXNBgz3UC48kpmKLQ0HdsfwDHNqScj 8EBTCxjKw==; Received: from ip-64-134-224-158.public.wayport.net ([64.134.224.158] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dQZax-0003qY-HI; Thu, 29 Jun 2017 13:34:55 +0000 From: Christoph Hellwig To: trond.myklebust@primarydata.com Cc: jlayton@poochiereds.net, schumaker.anna@gmail.com, bfields@fieldses.org, linux-nfs@vger.kernel.org, Peng Tao Subject: [PATCH 2/4] nfs: add a nfs_ilookup helper Date: Thu, 29 Jun 2017 06:34:51 -0700 Message-Id: <20170629133453.19641-3-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170629133453.19641-1-hch@lst.de> References: <20170629133453.19641-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peng Tao This helper will allow to find an existing NFS inode by the file handle and fattr. Signed-off-by: Peng Tao [hch: split from a larger patch] Signed-off-by: Christoph Hellwig --- fs/nfs/inode.c | 22 ++++++++++++++++++++++ include/linux/nfs_fs.h | 1 + 2 files changed, 23 insertions(+) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 1de93ba78dc9..a84eab1a18a7 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -386,6 +386,28 @@ void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr, #endif EXPORT_SYMBOL_GPL(nfs_setsecurity); +/* Search for inode identified by fh, fileid and i_mode in inode cache. */ +struct inode * +nfs_ilookup(struct super_block *sb, struct nfs_fattr *fattr, struct nfs_fh *fh) +{ + struct nfs_find_desc desc = { + .fh = fh, + .fattr = fattr, + }; + struct inode *inode; + unsigned long hash; + + if (!(fattr->valid & NFS_ATTR_FATTR_FILEID) || + !(fattr->valid & NFS_ATTR_FATTR_TYPE)) + return NULL; + + hash = nfs_fattr_to_ino_t(fattr); + inode = ilookup5(sb, hash, nfs_find_actor, &desc); + + dprintk("%s: returning %p\n", __func__, inode); + return inode; +} + /* * This is our front-end to iget that looks up inodes by file handle * instead of inode number. diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index bb0eb2c9acca..e52cc55ac300 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -332,6 +332,7 @@ extern void nfs_zap_caches(struct inode *); extern void nfs_invalidate_atime(struct inode *); extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *); +struct inode *nfs_ilookup(struct super_block *sb, struct nfs_fattr *, struct nfs_fh *); extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *); extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr); extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);