Skip to content

Commit f174ff7

Browse files
Peng Taoamschuma-ntap
authored andcommitted
nfs: add a nfs_ilookup helper
This helper will allow to find an existing NFS inode by the file handle and fattr. Signed-off-by: Peng Tao <[email protected]> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 774d951 commit f174ff7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

fs/nfs/inode.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,28 @@ void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr,
386386
#endif
387387
EXPORT_SYMBOL_GPL(nfs_setsecurity);
388388

389+
/* Search for inode identified by fh, fileid and i_mode in inode cache. */
390+
struct inode *
391+
nfs_ilookup(struct super_block *sb, struct nfs_fattr *fattr, struct nfs_fh *fh)
392+
{
393+
struct nfs_find_desc desc = {
394+
.fh = fh,
395+
.fattr = fattr,
396+
};
397+
struct inode *inode;
398+
unsigned long hash;
399+
400+
if (!(fattr->valid & NFS_ATTR_FATTR_FILEID) ||
401+
!(fattr->valid & NFS_ATTR_FATTR_TYPE))
402+
return NULL;
403+
404+
hash = nfs_fattr_to_ino_t(fattr);
405+
inode = ilookup5(sb, hash, nfs_find_actor, &desc);
406+
407+
dprintk("%s: returning %p\n", __func__, inode);
408+
return inode;
409+
}
410+
389411
/*
390412
* This is our front-end to iget that looks up inodes by file handle
391413
* instead of inode number.

include/linux/nfs_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ extern void nfs_zap_caches(struct inode *);
332332
extern void nfs_invalidate_atime(struct inode *);
333333
extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
334334
struct nfs_fattr *, struct nfs4_label *);
335+
struct inode *nfs_ilookup(struct super_block *sb, struct nfs_fattr *, struct nfs_fh *);
335336
extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
336337
extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
337338
extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);

0 commit comments

Comments
 (0)