diff options
Diffstat (limited to 'fs/nfs/callback_proc.c')
-rw-r--r-- | fs/nfs/callback_proc.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index b7da1f54da68..defa9b4c470e 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
@@ -61,6 +61,16 @@ out: | |||
61 | return res->status; | 61 | return res->status; |
62 | } | 62 | } |
63 | 63 | ||
64 | static int (*nfs_validate_delegation_stateid(struct nfs_client *clp))(struct nfs_delegation *, const nfs4_stateid *) | ||
65 | { | ||
66 | #if defined(CONFIG_NFS_V4_1) | ||
67 | if (clp->cl_minorversion > 0) | ||
68 | return nfs41_validate_delegation_stateid; | ||
69 | #endif | ||
70 | return nfs4_validate_delegation_stateid; | ||
71 | } | ||
72 | |||
73 | |||
64 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | 74 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) |
65 | { | 75 | { |
66 | struct nfs_client *clp; | 76 | struct nfs_client *clp; |
@@ -81,7 +91,8 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | |||
81 | inode = nfs_delegation_find_inode(clp, &args->fh); | 91 | inode = nfs_delegation_find_inode(clp, &args->fh); |
82 | if (inode != NULL) { | 92 | if (inode != NULL) { |
83 | /* Set up a helper thread to actually return the delegation */ | 93 | /* Set up a helper thread to actually return the delegation */ |
84 | switch(nfs_async_inode_return_delegation(inode, &args->stateid)) { | 94 | switch (nfs_async_inode_return_delegation(inode, &args->stateid, |
95 | nfs_validate_delegation_stateid(clp))) { | ||
85 | case 0: | 96 | case 0: |
86 | res = 0; | 97 | res = 0; |
87 | break; | 98 | break; |
@@ -102,8 +113,31 @@ out: | |||
102 | return res; | 113 | return res; |
103 | } | 114 | } |
104 | 115 | ||
116 | int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
117 | { | ||
118 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, | ||
119 | sizeof(delegation->stateid.data)) != 0) | ||
120 | return 0; | ||
121 | return 1; | ||
122 | } | ||
123 | |||
105 | #if defined(CONFIG_NFS_V4_1) | 124 | #if defined(CONFIG_NFS_V4_1) |
106 | 125 | ||
126 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
127 | { | ||
128 | if (delegation == NULL) | ||
129 | return 0; | ||
130 | |||
131 | /* seqid is 4-bytes long */ | ||
132 | if (((u32 *) &stateid->data)[0] != 0) | ||
133 | return 0; | ||
134 | if (memcmp(&delegation->stateid.data[4], &stateid->data[4], | ||
135 | sizeof(stateid->data)-4)) | ||
136 | return 0; | ||
137 | |||
138 | return 1; | ||
139 | } | ||
140 | |||
107 | /* | 141 | /* |
108 | * Validate the sequenceID sent by the server. | 142 | * Validate the sequenceID sent by the server. |
109 | * Return success if the sequenceID is one more than what we last saw on | 143 | * Return success if the sequenceID is one more than what we last saw on |
@@ -227,4 +261,32 @@ out: | |||
227 | return res->csr_status; | 261 | return res->csr_status; |
228 | } | 262 | } |
229 | 263 | ||
264 | unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy) | ||
265 | { | ||
266 | struct nfs_client *clp; | ||
267 | int status; | ||
268 | fmode_t flags = 0; | ||
269 | |||
270 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); | ||
271 | clp = nfs_find_client(args->craa_addr, 4); | ||
272 | if (clp == NULL) | ||
273 | goto out; | ||
274 | |||
275 | dprintk("NFS: RECALL_ANY callback request from %s\n", | ||
276 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); | ||
277 | |||
278 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) | ||
279 | &args->craa_type_mask)) | ||
280 | flags = FMODE_READ; | ||
281 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) | ||
282 | &args->craa_type_mask)) | ||
283 | flags |= FMODE_WRITE; | ||
284 | |||
285 | if (flags) | ||
286 | nfs_expire_all_delegation_types(clp, flags); | ||
287 | status = htonl(NFS4_OK); | ||
288 | out: | ||
289 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); | ||
290 | return status; | ||
291 | } | ||
230 | #endif /* CONFIG_NFS_V4_1 */ | 292 | #endif /* CONFIG_NFS_V4_1 */ |