Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/nfs/callback_proc.c |
| 3 | * |
| 4 | * Copyright (C) 2004 Trond Myklebust |
| 5 | * |
| 6 | * NFSv4 callback procedures |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/nfs4.h> |
| 9 | #include <linux/nfs_fs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 11 | #include "nfs4_fs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include "callback.h" |
| 13 | #include "delegation.h" |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 14 | #include "internal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 16 | #ifdef NFS_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #define NFSDBG_FACILITY NFSDBG_CALLBACK |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 18 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Al Viro | e6f684f | 2006-10-19 23:28:50 -0700 | [diff] [blame] | 20 | __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | { |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 22 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | struct nfs_delegation *delegation; |
| 24 | struct nfs_inode *nfsi; |
| 25 | struct inode *inode; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | res->bitmap[0] = res->bitmap[1] = 0; |
| 28 | res->status = htonl(NFS4ERR_BADHANDLE); |
Chuck Lever | ff05264 | 2007-12-10 14:58:44 -0500 | [diff] [blame] | 29 | clp = nfs_find_client(args->addr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | if (clp == NULL) |
| 31 | goto out; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 32 | |
| 33 | dprintk("NFS: GETATTR callback request from %s\n", |
| 34 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | inode = nfs_delegation_find_inode(clp, &args->fh); |
| 37 | if (inode == NULL) |
| 38 | goto out_putclient; |
| 39 | nfsi = NFS_I(inode); |
Trond Myklebust | 761fe93 | 2010-08-04 09:29:52 -0400 | [diff] [blame] | 40 | rcu_read_lock(); |
| 41 | delegation = rcu_dereference(nfsi->delegation); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0) |
| 43 | goto out_iput; |
| 44 | res->size = i_size_read(inode); |
Trond Myklebust | beb2a5e | 2006-01-03 09:55:37 +0100 | [diff] [blame] | 45 | res->change_attr = delegation->change_attr; |
| 46 | if (nfsi->npages != 0) |
| 47 | res->change_attr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | res->ctime = inode->i_ctime; |
| 49 | res->mtime = inode->i_mtime; |
| 50 | res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) & |
| 51 | args->bitmap[0]; |
| 52 | res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) & |
| 53 | args->bitmap[1]; |
| 54 | res->status = 0; |
| 55 | out_iput: |
Trond Myklebust | 761fe93 | 2010-08-04 09:29:52 -0400 | [diff] [blame] | 56 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | iput(inode); |
| 58 | out_putclient: |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 59 | nfs_put_client(clp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 61 | dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | return res->status; |
| 63 | } |
| 64 | |
Al Viro | e6f684f | 2006-10-19 23:28:50 -0700 | [diff] [blame] | 65 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 67 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | struct inode *inode; |
Al Viro | e6f684f | 2006-10-19 23:28:50 -0700 | [diff] [blame] | 69 | __be32 res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | res = htonl(NFS4ERR_BADHANDLE); |
Chuck Lever | ff05264 | 2007-12-10 14:58:44 -0500 | [diff] [blame] | 72 | clp = nfs_find_client(args->addr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | if (clp == NULL) |
| 74 | goto out; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 75 | |
| 76 | dprintk("NFS: RECALL callback request from %s\n", |
| 77 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
| 78 | |
Trond Myklebust | 3fbd67a | 2008-01-26 01:06:40 -0500 | [diff] [blame] | 79 | do { |
| 80 | struct nfs_client *prev = clp; |
| 81 | |
| 82 | inode = nfs_delegation_find_inode(clp, &args->fh); |
| 83 | if (inode != NULL) { |
| 84 | /* Set up a helper thread to actually return the delegation */ |
Trond Myklebust | e047a10 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 85 | switch (nfs_async_inode_return_delegation(inode, &args->stateid)) { |
Trond Myklebust | 3fbd67a | 2008-01-26 01:06:40 -0500 | [diff] [blame] | 86 | case 0: |
| 87 | res = 0; |
| 88 | break; |
| 89 | case -ENOENT: |
| 90 | if (res != 0) |
| 91 | res = htonl(NFS4ERR_BAD_STATEID); |
| 92 | break; |
| 93 | default: |
| 94 | res = htonl(NFS4ERR_RESOURCE); |
| 95 | } |
| 96 | iput(inode); |
| 97 | } |
| 98 | clp = nfs_find_client_next(prev); |
| 99 | nfs_put_client(prev); |
| 100 | } while (clp != NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 102 | dprintk("%s: exit with status = %d\n", __func__, ntohl(res)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | return res; |
| 104 | } |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 105 | |
Alexandros Batsakis | 2597641 | 2009-12-05 13:48:55 -0500 | [diff] [blame] | 106 | int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) |
| 107 | { |
| 108 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, |
| 109 | sizeof(delegation->stateid.data)) != 0) |
| 110 | return 0; |
| 111 | return 1; |
| 112 | } |
| 113 | |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 114 | #if defined(CONFIG_NFS_V4_1) |
| 115 | |
Alexandros Batsakis | 2597641 | 2009-12-05 13:48:55 -0500 | [diff] [blame] | 116 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) |
| 117 | { |
| 118 | if (delegation == NULL) |
| 119 | return 0; |
| 120 | |
| 121 | /* seqid is 4-bytes long */ |
| 122 | if (((u32 *) &stateid->data)[0] != 0) |
| 123 | return 0; |
| 124 | if (memcmp(&delegation->stateid.data[4], &stateid->data[4], |
| 125 | sizeof(stateid->data)-4)) |
| 126 | return 0; |
| 127 | |
| 128 | return 1; |
| 129 | } |
| 130 | |
Ricardo Labiaga | 963891a | 2009-04-01 09:23:34 -0400 | [diff] [blame] | 131 | /* |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 132 | * Validate the sequenceID sent by the server. |
| 133 | * Return success if the sequenceID is one more than what we last saw on |
| 134 | * this slot, accounting for wraparound. Increments the slot's sequence. |
| 135 | * |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 136 | * We don't yet implement a duplicate request cache, instead we set the |
| 137 | * back channel ca_maxresponsesize_cached to zero. This is OK for now |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 138 | * since we only currently implement idempotent callbacks anyway. |
| 139 | * |
| 140 | * We have a single slot backchannel at this time, so we don't bother |
| 141 | * checking the used_slots bit array on the table. The lower layer guarantees |
| 142 | * a single outstanding callback request at a time. |
| 143 | */ |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 144 | static __be32 |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 145 | validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 146 | { |
| 147 | struct nfs4_slot *slot; |
| 148 | |
| 149 | dprintk("%s enter. slotid %d seqid %d\n", |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 150 | __func__, args->csa_slotid, args->csa_sequenceid); |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 151 | |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 152 | if (args->csa_slotid > NFS41_BC_MAX_CALLBACKS) |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 153 | return htonl(NFS4ERR_BADSLOT); |
| 154 | |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 155 | slot = tbl->slots + args->csa_slotid; |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 156 | dprintk("%s slot table seqid: %d\n", __func__, slot->seq_nr); |
| 157 | |
| 158 | /* Normal */ |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 159 | if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 160 | slot->seq_nr++; |
| 161 | return htonl(NFS4_OK); |
| 162 | } |
| 163 | |
| 164 | /* Replay */ |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 165 | if (args->csa_sequenceid == slot->seq_nr) { |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 166 | dprintk("%s seqid %d is a replay\n", |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 167 | __func__, args->csa_sequenceid); |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 168 | /* Signal process_op to set this error on next op */ |
| 169 | if (args->csa_cachethis == 0) |
| 170 | return htonl(NFS4ERR_RETRY_UNCACHED_REP); |
| 171 | |
| 172 | /* The ca_maxresponsesize_cached is 0 with no DRC */ |
| 173 | else if (args->csa_cachethis == 1) |
| 174 | return htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE); |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /* Wraparound */ |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 178 | if (args->csa_sequenceid == 1 && (slot->seq_nr + 1) == 0) { |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 179 | slot->seq_nr = 1; |
| 180 | return htonl(NFS4_OK); |
| 181 | } |
| 182 | |
| 183 | /* Misordered request */ |
| 184 | return htonl(NFS4ERR_SEQ_MISORDERED); |
| 185 | } |
| 186 | |
| 187 | /* |
Ricardo Labiaga | 963891a | 2009-04-01 09:23:34 -0400 | [diff] [blame] | 188 | * Returns a pointer to a held 'struct nfs_client' that matches the server's |
| 189 | * address, major version number, and session ID. It is the caller's |
| 190 | * responsibility to release the returned reference. |
| 191 | * |
| 192 | * Returns NULL if there are no connections with sessions, or if no session |
| 193 | * matches the one of interest. |
| 194 | */ |
| 195 | static struct nfs_client *find_client_with_session( |
| 196 | const struct sockaddr *addr, u32 nfsversion, |
| 197 | struct nfs4_sessionid *sessionid) |
| 198 | { |
| 199 | struct nfs_client *clp; |
| 200 | |
| 201 | clp = nfs_find_client(addr, 4); |
| 202 | if (clp == NULL) |
| 203 | return NULL; |
| 204 | |
| 205 | do { |
| 206 | struct nfs_client *prev = clp; |
| 207 | |
| 208 | if (clp->cl_session != NULL) { |
| 209 | if (memcmp(clp->cl_session->sess_id.data, |
| 210 | sessionid->data, |
| 211 | NFS4_MAX_SESSIONID_LEN) == 0) { |
| 212 | /* Returns a held reference to clp */ |
| 213 | return clp; |
| 214 | } |
| 215 | } |
| 216 | clp = nfs_find_client_next(prev); |
| 217 | nfs_put_client(prev); |
| 218 | } while (clp != NULL); |
| 219 | |
| 220 | return NULL; |
| 221 | } |
| 222 | |
Mike Sager | a7989c3 | 2010-01-19 12:54:40 -0500 | [diff] [blame] | 223 | /* |
| 224 | * For each referring call triple, check the session's slot table for |
| 225 | * a match. If the slot is in use and the sequence numbers match, the |
| 226 | * client is still waiting for a response to the original request. |
| 227 | */ |
| 228 | static bool referring_call_exists(struct nfs_client *clp, |
| 229 | uint32_t nrclists, |
| 230 | struct referring_call_list *rclists) |
| 231 | { |
| 232 | bool status = 0; |
| 233 | int i, j; |
| 234 | struct nfs4_session *session; |
| 235 | struct nfs4_slot_table *tbl; |
| 236 | struct referring_call_list *rclist; |
| 237 | struct referring_call *ref; |
| 238 | |
| 239 | /* |
| 240 | * XXX When client trunking is implemented, this becomes |
| 241 | * a session lookup from within the loop |
| 242 | */ |
| 243 | session = clp->cl_session; |
| 244 | tbl = &session->fc_slot_table; |
| 245 | |
| 246 | for (i = 0; i < nrclists; i++) { |
| 247 | rclist = &rclists[i]; |
| 248 | if (memcmp(session->sess_id.data, |
| 249 | rclist->rcl_sessionid.data, |
| 250 | NFS4_MAX_SESSIONID_LEN) != 0) |
| 251 | continue; |
| 252 | |
| 253 | for (j = 0; j < rclist->rcl_nrefcalls; j++) { |
| 254 | ref = &rclist->rcl_refcalls[j]; |
| 255 | |
| 256 | dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u " |
| 257 | "slotid %u\n", __func__, |
| 258 | ((u32 *)&rclist->rcl_sessionid.data)[0], |
| 259 | ((u32 *)&rclist->rcl_sessionid.data)[1], |
| 260 | ((u32 *)&rclist->rcl_sessionid.data)[2], |
| 261 | ((u32 *)&rclist->rcl_sessionid.data)[3], |
| 262 | ref->rc_sequenceid, ref->rc_slotid); |
| 263 | |
| 264 | spin_lock(&tbl->slot_tbl_lock); |
| 265 | status = (test_bit(ref->rc_slotid, tbl->used_slots) && |
| 266 | tbl->slots[ref->rc_slotid].seq_nr == |
| 267 | ref->rc_sequenceid); |
| 268 | spin_unlock(&tbl->slot_tbl_lock); |
| 269 | if (status) |
| 270 | goto out; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | out: |
| 275 | return status; |
| 276 | } |
| 277 | |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 278 | __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 279 | struct cb_sequenceres *res) |
| 280 | { |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 281 | struct nfs_client *clp; |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 282 | int i; |
| 283 | __be32 status; |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 284 | |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 285 | status = htonl(NFS4ERR_BADSESSION); |
| 286 | clp = find_client_with_session(args->csa_addr, 4, &args->csa_sessionid); |
| 287 | if (clp == NULL) |
| 288 | goto out; |
| 289 | |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 290 | status = validate_seqid(&clp->cl_session->bc_slot_table, args); |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 291 | if (status) |
| 292 | goto out_putclient; |
| 293 | |
Mike Sager | 72ce2b3 | 2010-01-19 12:54:41 -0500 | [diff] [blame] | 294 | /* |
| 295 | * Check for pending referring calls. If a match is found, a |
| 296 | * related callback was received before the response to the original |
| 297 | * call. |
| 298 | */ |
| 299 | if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) { |
| 300 | status = htonl(NFS4ERR_DELAY); |
| 301 | goto out_putclient; |
| 302 | } |
| 303 | |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 304 | memcpy(&res->csr_sessionid, &args->csa_sessionid, |
| 305 | sizeof(res->csr_sessionid)); |
| 306 | res->csr_sequenceid = args->csa_sequenceid; |
| 307 | res->csr_slotid = args->csa_slotid; |
| 308 | res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
| 309 | res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
| 310 | |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 311 | out_putclient: |
| 312 | nfs_put_client(clp); |
| 313 | out: |
Mike Sager | 72ce2b3 | 2010-01-19 12:54:41 -0500 | [diff] [blame] | 314 | for (i = 0; i < args->csa_nrclists; i++) |
| 315 | kfree(args->csa_rclists[i].rcl_refcalls); |
| 316 | kfree(args->csa_rclists); |
| 317 | |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 318 | if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) |
| 319 | res->csr_status = 0; |
| 320 | else |
| 321 | res->csr_status = status; |
| 322 | dprintk("%s: exit with status = %d res->csr_status %d\n", __func__, |
| 323 | ntohl(status), ntohl(res->csr_status)); |
| 324 | return status; |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 325 | } |
| 326 | |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 327 | __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy) |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 328 | { |
| 329 | struct nfs_client *clp; |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 330 | __be32 status; |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 331 | fmode_t flags = 0; |
| 332 | |
| 333 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
| 334 | clp = nfs_find_client(args->craa_addr, 4); |
| 335 | if (clp == NULL) |
| 336 | goto out; |
| 337 | |
| 338 | dprintk("NFS: RECALL_ANY callback request from %s\n", |
| 339 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
| 340 | |
| 341 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) |
| 342 | &args->craa_type_mask)) |
| 343 | flags = FMODE_READ; |
| 344 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) |
| 345 | &args->craa_type_mask)) |
| 346 | flags |= FMODE_WRITE; |
| 347 | |
| 348 | if (flags) |
| 349 | nfs_expire_all_delegation_types(clp, flags); |
| 350 | status = htonl(NFS4_OK); |
| 351 | out: |
| 352 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); |
| 353 | return status; |
| 354 | } |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 355 | |
| 356 | /* Reduce the fore channel's max_slots to the target value */ |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 357 | __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy) |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 358 | { |
| 359 | struct nfs_client *clp; |
| 360 | struct nfs4_slot_table *fc_tbl; |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 361 | __be32 status; |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 362 | |
| 363 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
| 364 | clp = nfs_find_client(args->crsa_addr, 4); |
| 365 | if (clp == NULL) |
| 366 | goto out; |
| 367 | |
| 368 | dprintk("NFS: CB_RECALL_SLOT request from %s target max slots %d\n", |
| 369 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR), |
| 370 | args->crsa_target_max_slots); |
| 371 | |
| 372 | fc_tbl = &clp->cl_session->fc_slot_table; |
| 373 | |
| 374 | status = htonl(NFS4ERR_BAD_HIGH_SLOT); |
Andy Adamson | bae0ac0 | 2010-01-21 14:19:16 -0500 | [diff] [blame] | 375 | if (args->crsa_target_max_slots > fc_tbl->max_slots || |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 376 | args->crsa_target_max_slots < 1) |
Andy Adamson | bae0ac0 | 2010-01-21 14:19:16 -0500 | [diff] [blame] | 377 | goto out_putclient; |
| 378 | |
| 379 | status = htonl(NFS4_OK); |
| 380 | if (args->crsa_target_max_slots == fc_tbl->max_slots) |
| 381 | goto out_putclient; |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 382 | |
| 383 | fc_tbl->target_max_slots = args->crsa_target_max_slots; |
| 384 | nfs41_handle_recall_slot(clp); |
Andy Adamson | bae0ac0 | 2010-01-21 14:19:16 -0500 | [diff] [blame] | 385 | out_putclient: |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 386 | nfs_put_client(clp); /* balance nfs_find_client */ |
| 387 | out: |
| 388 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); |
| 389 | return status; |
| 390 | } |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 391 | #endif /* CONFIG_NFS_V4_1 */ |