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 |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 19 | |
| 20 | __be32 nfs4_callback_getattr(struct cb_getattrargs *args, |
| 21 | struct cb_getattrres *res, |
| 22 | struct cb_process_state *cps) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | struct nfs_delegation *delegation; |
| 25 | struct nfs_inode *nfsi; |
| 26 | struct inode *inode; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 27 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 28 | res->status = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
| 29 | if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | goto out; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 31 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 32 | res->bitmap[0] = res->bitmap[1] = 0; |
| 33 | res->status = htonl(NFS4ERR_BADHANDLE); |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 34 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 35 | dprintk("NFS: GETATTR callback request from %s\n", |
| 36 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
| 37 | |
| 38 | inode = nfs_delegation_find_inode(cps->clp, &args->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | if (inode == NULL) |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 40 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | nfsi = NFS_I(inode); |
Trond Myklebust | 761fe93 | 2010-08-04 09:29:52 -0400 | [diff] [blame] | 42 | rcu_read_lock(); |
| 43 | delegation = rcu_dereference(nfsi->delegation); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0) |
| 45 | goto out_iput; |
| 46 | res->size = i_size_read(inode); |
Trond Myklebust | beb2a5e | 2006-01-03 09:55:37 +0100 | [diff] [blame] | 47 | res->change_attr = delegation->change_attr; |
| 48 | if (nfsi->npages != 0) |
| 49 | res->change_attr++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | res->ctime = inode->i_ctime; |
| 51 | res->mtime = inode->i_mtime; |
| 52 | res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) & |
| 53 | args->bitmap[0]; |
| 54 | res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) & |
| 55 | args->bitmap[1]; |
| 56 | res->status = 0; |
| 57 | out_iput: |
Trond Myklebust | 761fe93 | 2010-08-04 09:29:52 -0400 | [diff] [blame] | 58 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | iput(inode); |
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 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 65 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy, |
| 66 | struct cb_process_state *cps) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
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 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 71 | res = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
| 72 | if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | goto out; |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 74 | |
| 75 | dprintk("NFS: RECALL callback request from %s\n", |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 76 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
Chuck Lever | 1d98fe6 | 2007-12-10 14:57:23 -0500 | [diff] [blame] | 77 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 78 | res = htonl(NFS4ERR_BADHANDLE); |
| 79 | inode = nfs_delegation_find_inode(cps->clp, &args->fh); |
| 80 | if (inode == NULL) |
| 81 | goto out; |
| 82 | /* Set up a helper thread to actually return the delegation */ |
| 83 | switch (nfs_async_inode_return_delegation(inode, &args->stateid)) { |
| 84 | case 0: |
| 85 | res = 0; |
| 86 | break; |
| 87 | case -ENOENT: |
| 88 | if (res != 0) |
| 89 | res = htonl(NFS4ERR_BAD_STATEID); |
| 90 | break; |
| 91 | default: |
| 92 | res = htonl(NFS4ERR_RESOURCE); |
| 93 | } |
| 94 | iput(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 96 | dprintk("%s: exit with status = %d\n", __func__, ntohl(res)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | return res; |
| 98 | } |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 99 | |
Alexandros Batsakis | 2597641 | 2009-12-05 13:48:55 -0500 | [diff] [blame] | 100 | int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) |
| 101 | { |
| 102 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, |
| 103 | sizeof(delegation->stateid.data)) != 0) |
| 104 | return 0; |
| 105 | return 1; |
| 106 | } |
| 107 | |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 108 | #if defined(CONFIG_NFS_V4_1) |
| 109 | |
Fred Isaman | f2a6256 | 2011-01-06 11:36:29 +0000 | [diff] [blame^] | 110 | __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args, |
| 111 | void *dummy, struct cb_process_state *cps) |
| 112 | { |
| 113 | return cpu_to_be32(NFS4ERR_NOTSUPP); /* STUB */ |
| 114 | } |
| 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 | |
Alexandros Batsakis | 9449925 | 2010-10-20 00:17:56 -0400 | [diff] [blame] | 121 | if (stateid->stateid.seqid != 0) |
Alexandros Batsakis | 2597641 | 2009-12-05 13:48:55 -0500 | [diff] [blame] | 122 | return 0; |
Alexandros Batsakis | 9449925 | 2010-10-20 00:17:56 -0400 | [diff] [blame] | 123 | if (memcmp(&delegation->stateid.stateid.other, |
| 124 | &stateid->stateid.other, |
| 125 | NFS4_STATEID_OTHER_SIZE)) |
Alexandros Batsakis | 2597641 | 2009-12-05 13:48:55 -0500 | [diff] [blame] | 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 | /* |
Mike Sager | a7989c3 | 2010-01-19 12:54:40 -0500 | [diff] [blame] | 188 | * For each referring call triple, check the session's slot table for |
| 189 | * a match. If the slot is in use and the sequence numbers match, the |
| 190 | * client is still waiting for a response to the original request. |
| 191 | */ |
| 192 | static bool referring_call_exists(struct nfs_client *clp, |
| 193 | uint32_t nrclists, |
| 194 | struct referring_call_list *rclists) |
| 195 | { |
| 196 | bool status = 0; |
| 197 | int i, j; |
| 198 | struct nfs4_session *session; |
| 199 | struct nfs4_slot_table *tbl; |
| 200 | struct referring_call_list *rclist; |
| 201 | struct referring_call *ref; |
| 202 | |
| 203 | /* |
| 204 | * XXX When client trunking is implemented, this becomes |
| 205 | * a session lookup from within the loop |
| 206 | */ |
| 207 | session = clp->cl_session; |
| 208 | tbl = &session->fc_slot_table; |
| 209 | |
| 210 | for (i = 0; i < nrclists; i++) { |
| 211 | rclist = &rclists[i]; |
| 212 | if (memcmp(session->sess_id.data, |
| 213 | rclist->rcl_sessionid.data, |
| 214 | NFS4_MAX_SESSIONID_LEN) != 0) |
| 215 | continue; |
| 216 | |
| 217 | for (j = 0; j < rclist->rcl_nrefcalls; j++) { |
| 218 | ref = &rclist->rcl_refcalls[j]; |
| 219 | |
| 220 | dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u " |
| 221 | "slotid %u\n", __func__, |
| 222 | ((u32 *)&rclist->rcl_sessionid.data)[0], |
| 223 | ((u32 *)&rclist->rcl_sessionid.data)[1], |
| 224 | ((u32 *)&rclist->rcl_sessionid.data)[2], |
| 225 | ((u32 *)&rclist->rcl_sessionid.data)[3], |
| 226 | ref->rc_sequenceid, ref->rc_slotid); |
| 227 | |
| 228 | spin_lock(&tbl->slot_tbl_lock); |
| 229 | status = (test_bit(ref->rc_slotid, tbl->used_slots) && |
| 230 | tbl->slots[ref->rc_slotid].seq_nr == |
| 231 | ref->rc_sequenceid); |
| 232 | spin_unlock(&tbl->slot_tbl_lock); |
| 233 | if (status) |
| 234 | goto out; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | out: |
| 239 | return status; |
| 240 | } |
| 241 | |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 242 | __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 243 | struct cb_sequenceres *res, |
| 244 | struct cb_process_state *cps) |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 245 | { |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 246 | struct nfs_client *clp; |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 247 | int i; |
| 248 | __be32 status; |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 249 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 250 | cps->clp = NULL; |
| 251 | |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 252 | status = htonl(NFS4ERR_BADSESSION); |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 253 | /* Incoming session must match the callback session */ |
| 254 | if (memcmp(&args->csa_sessionid, cps->svc_sid, NFS4_MAX_SESSIONID_LEN)) |
| 255 | goto out; |
| 256 | |
| 257 | clp = nfs4_find_client_sessionid(args->csa_addr, |
| 258 | &args->csa_sessionid, 1); |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 259 | if (clp == NULL) |
| 260 | goto out; |
| 261 | |
Andy Adamson | 42acd02 | 2011-01-06 02:04:34 +0000 | [diff] [blame] | 262 | /* state manager is resetting the session */ |
| 263 | if (test_bit(NFS4_SESSION_DRAINING, &clp->cl_session->session_state)) { |
| 264 | status = NFS4ERR_DELAY; |
| 265 | goto out; |
| 266 | } |
| 267 | |
Andy Adamson | b2f28bd | 2010-01-14 17:45:07 -0500 | [diff] [blame] | 268 | status = validate_seqid(&clp->cl_session->bc_slot_table, args); |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 269 | if (status) |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 270 | goto out; |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 271 | |
Mike Sager | 72ce2b3 | 2010-01-19 12:54:41 -0500 | [diff] [blame] | 272 | /* |
| 273 | * Check for pending referring calls. If a match is found, a |
| 274 | * related callback was received before the response to the original |
| 275 | * call. |
| 276 | */ |
| 277 | if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) { |
| 278 | status = htonl(NFS4ERR_DELAY); |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 279 | goto out; |
Mike Sager | 72ce2b3 | 2010-01-19 12:54:41 -0500 | [diff] [blame] | 280 | } |
| 281 | |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 282 | memcpy(&res->csr_sessionid, &args->csa_sessionid, |
| 283 | sizeof(res->csr_sessionid)); |
| 284 | res->csr_sequenceid = args->csa_sequenceid; |
| 285 | res->csr_slotid = args->csa_slotid; |
| 286 | res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
| 287 | res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; |
Andy Adamson | 42acd02 | 2011-01-06 02:04:34 +0000 | [diff] [blame] | 288 | nfs4_cb_take_slot(clp); |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 289 | cps->clp = clp; /* put in nfs4_callback_compound */ |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 290 | |
Ricardo Labiaga | 68f3f90 | 2009-04-01 09:23:35 -0400 | [diff] [blame] | 291 | out: |
Mike Sager | 72ce2b3 | 2010-01-19 12:54:41 -0500 | [diff] [blame] | 292 | for (i = 0; i < args->csa_nrclists; i++) |
| 293 | kfree(args->csa_rclists[i].rcl_refcalls); |
| 294 | kfree(args->csa_rclists); |
| 295 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 296 | if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) { |
| 297 | cps->drc_status = status; |
| 298 | status = 0; |
| 299 | } else |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 300 | res->csr_status = status; |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 301 | |
Andy Adamson | 4911096 | 2010-01-14 17:45:08 -0500 | [diff] [blame] | 302 | dprintk("%s: exit with status = %d res->csr_status %d\n", __func__, |
| 303 | ntohl(status), ntohl(res->csr_status)); |
| 304 | return status; |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 305 | } |
| 306 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 307 | __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy, |
| 308 | struct cb_process_state *cps) |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 309 | { |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 310 | __be32 status; |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 311 | fmode_t flags = 0; |
| 312 | |
| 313 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 314 | if (!cps->clp) /* set in cb_sequence */ |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 315 | goto out; |
| 316 | |
| 317 | dprintk("NFS: RECALL_ANY callback request from %s\n", |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 318 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 319 | |
| 320 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) |
| 321 | &args->craa_type_mask)) |
| 322 | flags = FMODE_READ; |
| 323 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) |
| 324 | &args->craa_type_mask)) |
| 325 | flags |= FMODE_WRITE; |
| 326 | |
| 327 | if (flags) |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 328 | nfs_expire_all_delegation_types(cps->clp, flags); |
Alexandros Batsakis | 31f0960 | 2009-12-05 13:27:02 -0500 | [diff] [blame] | 329 | status = htonl(NFS4_OK); |
| 330 | out: |
| 331 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); |
| 332 | return status; |
| 333 | } |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 334 | |
| 335 | /* Reduce the fore channel's max_slots to the target value */ |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 336 | __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy, |
| 337 | struct cb_process_state *cps) |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 338 | { |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 339 | struct nfs4_slot_table *fc_tbl; |
Andy Adamson | 9733f0d | 2010-01-22 12:03:08 -0500 | [diff] [blame] | 340 | __be32 status; |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 341 | |
| 342 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 343 | if (!cps->clp) /* set in cb_sequence */ |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 344 | goto out; |
| 345 | |
| 346 | dprintk("NFS: CB_RECALL_SLOT request from %s target max slots %d\n", |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 347 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR), |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 348 | args->crsa_target_max_slots); |
| 349 | |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 350 | fc_tbl = &cps->clp->cl_session->fc_slot_table; |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 351 | |
| 352 | status = htonl(NFS4ERR_BAD_HIGH_SLOT); |
Andy Adamson | bae0ac0 | 2010-01-21 14:19:16 -0500 | [diff] [blame] | 353 | if (args->crsa_target_max_slots > fc_tbl->max_slots || |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 354 | args->crsa_target_max_slots < 1) |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 355 | goto out; |
Andy Adamson | bae0ac0 | 2010-01-21 14:19:16 -0500 | [diff] [blame] | 356 | |
| 357 | status = htonl(NFS4_OK); |
| 358 | if (args->crsa_target_max_slots == fc_tbl->max_slots) |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 359 | goto out; |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 360 | |
| 361 | fc_tbl->target_max_slots = args->crsa_target_max_slots; |
Andy Adamson | c36fca5 | 2011-01-06 02:04:32 +0000 | [diff] [blame] | 362 | nfs41_handle_recall_slot(cps->clp); |
Andy Adamson | b9efa1b | 2010-01-20 16:06:27 -0500 | [diff] [blame] | 363 | out: |
| 364 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); |
| 365 | return status; |
| 366 | } |
Benny Halevy | d49433e | 2009-04-01 09:23:25 -0400 | [diff] [blame] | 367 | #endif /* CONFIG_NFS_V4_1 */ |