Skip to content

Commit d2ae4f8

Browse files
fllindenTrond Myklebust
authored andcommitted
nfs: define nfs_access_get_cached function
The only consumer of nfs_access_get_cached_rcu and nfs_access_cached calls these static functions in order to first try RCU access, and then locked access. Combine them in to a single function, and call that. Make this function available to the rest of the NFS code. Signed-off-by: Frank van der Linden <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 3e1f021 commit d2ae4f8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

fs/nfs/dir.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, co
24602460
return NULL;
24612461
}
24622462

2463-
static int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, bool may_block)
2463+
static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, bool may_block)
24642464
{
24652465
struct nfs_inode *nfsi = NFS_I(inode);
24662466
struct nfs_access_entry *cache;
@@ -2533,6 +2533,20 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
25332533
return err;
25342534
}
25352535

2536+
int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct
2537+
nfs_access_entry *res, bool may_block)
2538+
{
2539+
int status;
2540+
2541+
status = nfs_access_get_cached_rcu(inode, cred, res);
2542+
if (status != 0)
2543+
status = nfs_access_get_cached_locked(inode, cred, res,
2544+
may_block);
2545+
2546+
return status;
2547+
}
2548+
EXPORT_SYMBOL_GPL(nfs_access_get_cached);
2549+
25362550
static void nfs_access_add_rbtree(struct inode *inode, struct nfs_access_entry *set)
25372551
{
25382552
struct nfs_inode *nfsi = NFS_I(inode);
@@ -2647,9 +2661,7 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask)
26472661

26482662
trace_nfs_access_enter(inode);
26492663

2650-
status = nfs_access_get_cached_rcu(inode, cred, &cache);
2651-
if (status != 0)
2652-
status = nfs_access_get_cached(inode, cred, &cache, may_block);
2664+
status = nfs_access_get_cached(inode, cred, &cache, may_block);
26532665
if (status == 0)
26542666
goto out_cached;
26552667

include/linux/nfs_fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
493493
struct nfs_fattr *fattr, struct nfs4_label *label);
494494
extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
495495
extern void nfs_access_zap_cache(struct inode *inode);
496+
extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res,
497+
bool may_block);
496498

497499
/*
498500
* linux/fs/nfs/symlink.c

0 commit comments

Comments
 (0)