diff options
author | Peng Tao <tao.peng@primarydata.com> | 2014-07-03 01:05:00 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-07-12 18:22:58 -0400 |
commit | 15bb3afe900dfe1714ba7c53b2582517627da995 (patch) | |
tree | 89fff5430a843e8af7a5069ddca7898fa1531729 /fs/nfs/delegation.c | |
parent | 0b0bc6ea77ec8430626e8c2f6cbdfb767b168ac1 (diff) |
nfs4: add nfs4_check_delegation
Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/delegation.c')
-rw-r--r-- | fs/nfs/delegation.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 5d8ccecf5f5c..5853f53db732 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -41,14 +41,8 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) | |||
41 | set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); | 41 | set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | static int |
45 | * nfs_have_delegation - check if inode has a delegation | 45 | nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) |
46 | * @inode: inode to check | ||
47 | * @flags: delegation types to check for | ||
48 | * | ||
49 | * Returns one if inode has the indicated delegation, otherwise zero. | ||
50 | */ | ||
51 | int nfs4_have_delegation(struct inode *inode, fmode_t flags) | ||
52 | { | 46 | { |
53 | struct nfs_delegation *delegation; | 47 | struct nfs_delegation *delegation; |
54 | int ret = 0; | 48 | int ret = 0; |
@@ -58,12 +52,34 @@ int nfs4_have_delegation(struct inode *inode, fmode_t flags) | |||
58 | delegation = rcu_dereference(NFS_I(inode)->delegation); | 52 | delegation = rcu_dereference(NFS_I(inode)->delegation); |
59 | if (delegation != NULL && (delegation->type & flags) == flags && | 53 | if (delegation != NULL && (delegation->type & flags) == flags && |
60 | !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { | 54 | !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { |
61 | nfs_mark_delegation_referenced(delegation); | 55 | if (mark) |
56 | nfs_mark_delegation_referenced(delegation); | ||
62 | ret = 1; | 57 | ret = 1; |
63 | } | 58 | } |
64 | rcu_read_unlock(); | 59 | rcu_read_unlock(); |
65 | return ret; | 60 | return ret; |
66 | } | 61 | } |
62 | /** | ||
63 | * nfs_have_delegation - check if inode has a delegation, mark it | ||
64 | * NFS_DELEGATION_REFERENCED if there is one. | ||
65 | * @inode: inode to check | ||
66 | * @flags: delegation types to check for | ||
67 | * | ||
68 | * Returns one if inode has the indicated delegation, otherwise zero. | ||
69 | */ | ||
70 | int nfs4_have_delegation(struct inode *inode, fmode_t flags) | ||
71 | { | ||
72 | return nfs4_do_check_delegation(inode, flags, true); | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * nfs4_check_delegation - check if inode has a delegation, do not mark | ||
77 | * NFS_DELEGATION_REFERENCED if it has one. | ||
78 | */ | ||
79 | int nfs4_check_delegation(struct inode *inode, fmode_t flags) | ||
80 | { | ||
81 | return nfs4_do_check_delegation(inode, flags, false); | ||
82 | } | ||
67 | 83 | ||
68 | static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid) | 84 | static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid) |
69 | { | 85 | { |