]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/nfs/callback_proc.c
NFSv4.1: Get rid of redundant NFS4CLNT_LAYOUTRECALL tests
[mirror_ubuntu-artful-kernel.git] / fs / nfs / callback_proc.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/nfs/callback_proc.c
3 *
4 * Copyright (C) 2004 Trond Myklebust
5 *
6 * NFSv4 callback procedures
7 */
1da177e4
LT
8#include <linux/nfs4.h>
9#include <linux/nfs_fs.h>
5a0e3ad6 10#include <linux/slab.h>
4ce79717 11#include "nfs4_fs.h"
1da177e4
LT
12#include "callback.h"
13#include "delegation.h"
24c8dbbb 14#include "internal.h"
43f1b3da 15#include "pnfs.h"
1da177e4 16
1d98fe67 17#ifdef NFS_DEBUG
1da177e4 18#define NFSDBG_FACILITY NFSDBG_CALLBACK
1d98fe67 19#endif
c36fca52
AA
20
21__be32 nfs4_callback_getattr(struct cb_getattrargs *args,
22 struct cb_getattrres *res,
23 struct cb_process_state *cps)
1da177e4 24{
1da177e4
LT
25 struct nfs_delegation *delegation;
26 struct nfs_inode *nfsi;
27 struct inode *inode;
1d98fe67 28
c36fca52
AA
29 res->status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
30 if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */
31 goto out;
32
1da177e4
LT
33 res->bitmap[0] = res->bitmap[1] = 0;
34 res->status = htonl(NFS4ERR_BADHANDLE);
1d98fe67
CL
35
36 dprintk("NFS: GETATTR callback request from %s\n",
c36fca52 37 rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
1d98fe67 38
c36fca52 39 inode = nfs_delegation_find_inode(cps->clp, &args->fh);
1da177e4 40 if (inode == NULL)
c36fca52 41 goto out;
1da177e4 42 nfsi = NFS_I(inode);
761fe93c
TM
43 rcu_read_lock();
44 delegation = rcu_dereference(nfsi->delegation);
1da177e4
LT
45 if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0)
46 goto out_iput;
47 res->size = i_size_read(inode);
beb2a5ec
TM
48 res->change_attr = delegation->change_attr;
49 if (nfsi->npages != 0)
50 res->change_attr++;
1da177e4
LT
51 res->ctime = inode->i_ctime;
52 res->mtime = inode->i_mtime;
53 res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
54 args->bitmap[0];
55 res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) &
56 args->bitmap[1];
57 res->status = 0;
58out_iput:
761fe93c 59 rcu_read_unlock();
1da177e4 60 iput(inode);
1da177e4 61out:
3110ff80 62 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
1da177e4
LT
63 return res->status;
64}
65
c36fca52
AA
66__be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
67 struct cb_process_state *cps)
1da177e4 68{
1da177e4 69 struct inode *inode;
e6f684f6 70 __be32 res;
1da177e4 71
c36fca52
AA
72 res = htonl(NFS4ERR_OP_NOT_IN_SESSION);
73 if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */
1da177e4 74 goto out;
1d98fe67
CL
75
76 dprintk("NFS: RECALL callback request from %s\n",
c36fca52
AA
77 rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
78
79 res = htonl(NFS4ERR_BADHANDLE);
80 inode = nfs_delegation_find_inode(cps->clp, &args->fh);
81 if (inode == NULL)
82 goto out;
83 /* Set up a helper thread to actually return the delegation */
84 switch (nfs_async_inode_return_delegation(inode, &args->stateid)) {
85 case 0:
86 res = 0;
87 break;
88 case -ENOENT:
89 if (res != 0)
90 res = htonl(NFS4ERR_BAD_STATEID);
91 break;
92 default:
93 res = htonl(NFS4ERR_RESOURCE);
94 }
95 iput(inode);
1da177e4 96out:
3110ff80 97 dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
1da177e4
LT
98 return res;
99}
d49433e1 100
2597641d
AB
101int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
102{
103 if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data,
104 sizeof(delegation->stateid.data)) != 0)
105 return 0;
106 return 1;
107}
108
d49433e1
BH
109#if defined(CONFIG_NFS_V4_1)
110
d36b7cf7
BH
111/*
112 * Lookup a layout by filehandle.
113 *
114 * Note: gets a refcount on the layout hdr and on its respective inode.
115 * Caller must put the layout hdr and the inode.
116 *
117 * TODO: keep track of all layouts (and delegations) in a hash table
118 * hashed by filehandle.
119 */
120static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp, struct nfs_fh *fh)
43f1b3da 121{
6382a441 122 struct nfs_server *server;
43f1b3da 123 struct inode *ino;
d36b7cf7 124 struct pnfs_layout_hdr *lo;
43f1b3da 125
6382a441
WAA
126 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
127 list_for_each_entry(lo, &server->layouts, plh_layouts) {
d36b7cf7 128 if (nfs_compare_fh(fh, &NFS_I(lo->plh_inode)->fh))
6382a441
WAA
129 continue;
130 ino = igrab(lo->plh_inode);
131 if (!ino)
132 continue;
6382a441 133 get_layout_hdr(lo);
d36b7cf7 134 return lo;
6382a441 135 }
43f1b3da 136 }
d36b7cf7
BH
137
138 return NULL;
139}
140
141static struct pnfs_layout_hdr * get_layout_by_fh(struct nfs_client *clp, struct nfs_fh *fh)
142{
143 struct pnfs_layout_hdr *lo;
144
145 spin_lock(&clp->cl_lock);
146 rcu_read_lock();
147 lo = get_layout_by_fh_locked(clp, fh);
6382a441 148 rcu_read_unlock();
43f1b3da 149 spin_unlock(&clp->cl_lock);
6382a441 150
d36b7cf7
BH
151 return lo;
152}
153
154static u32 initiate_file_draining(struct nfs_client *clp,
155 struct cb_layoutrecallargs *args)
156{
157 struct inode *ino;
158 struct pnfs_layout_hdr *lo;
159 u32 rv = NFS4ERR_NOMATCHING_LAYOUT;
160 LIST_HEAD(free_me_list);
161
162 lo = get_layout_by_fh(clp, &args->cbl_fh);
163 if (!lo)
43f1b3da
FI
164 return NFS4ERR_NOMATCHING_LAYOUT;
165
d36b7cf7 166 ino = lo->plh_inode;
43f1b3da
FI
167 spin_lock(&ino->i_lock);
168 if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
169 mark_matching_lsegs_invalid(lo, &free_me_list,
778b5502 170 &args->cbl_range))
43f1b3da
FI
171 rv = NFS4ERR_DELAY;
172 else
173 rv = NFS4ERR_NOMATCHING_LAYOUT;
174 pnfs_set_layout_stateid(lo, &args->cbl_stateid, true);
175 spin_unlock(&ino->i_lock);
176 pnfs_free_lseg_list(&free_me_list);
177 put_layout_hdr(lo);
178 iput(ino);
179 return rv;
180}
181
182static u32 initiate_bulk_draining(struct nfs_client *clp,
183 struct cb_layoutrecallargs *args)
184{
6382a441 185 struct nfs_server *server;
43f1b3da
FI
186 struct pnfs_layout_hdr *lo;
187 struct inode *ino;
188 u32 rv = NFS4ERR_NOMATCHING_LAYOUT;
189 struct pnfs_layout_hdr *tmp;
190 LIST_HEAD(recall_list);
191 LIST_HEAD(free_me_list);
192 struct pnfs_layout_range range = {
193 .iomode = IOMODE_ANY,
194 .offset = 0,
195 .length = NFS4_MAX_UINT64,
196 };
197
198 spin_lock(&clp->cl_lock);
6382a441
WAA
199 rcu_read_lock();
200 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
43f1b3da 201 if ((args->cbl_recall_type == RETURN_FSID) &&
6382a441
WAA
202 memcmp(&server->fsid, &args->cbl_fsid,
203 sizeof(struct nfs_fsid)))
43f1b3da 204 continue;
6382a441
WAA
205
206 list_for_each_entry(lo, &server->layouts, plh_layouts) {
207 if (!igrab(lo->plh_inode))
208 continue;
209 get_layout_hdr(lo);
210 BUG_ON(!list_empty(&lo->plh_bulk_recall));
211 list_add(&lo->plh_bulk_recall, &recall_list);
212 }
43f1b3da 213 }
6382a441 214 rcu_read_unlock();
43f1b3da 215 spin_unlock(&clp->cl_lock);
6382a441 216
43f1b3da
FI
217 list_for_each_entry_safe(lo, tmp,
218 &recall_list, plh_bulk_recall) {
219 ino = lo->plh_inode;
220 spin_lock(&ino->i_lock);
221 set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
778b5502 222 if (mark_matching_lsegs_invalid(lo, &free_me_list, &range))
43f1b3da
FI
223 rv = NFS4ERR_DELAY;
224 list_del_init(&lo->plh_bulk_recall);
225 spin_unlock(&ino->i_lock);
f49f9baa 226 pnfs_free_lseg_list(&free_me_list);
43f1b3da
FI
227 put_layout_hdr(lo);
228 iput(ino);
229 }
43f1b3da
FI
230 return rv;
231}
232
233static u32 do_callback_layoutrecall(struct nfs_client *clp,
234 struct cb_layoutrecallargs *args)
235{
236 u32 res = NFS4ERR_DELAY;
237
238 dprintk("%s enter, type=%i\n", __func__, args->cbl_recall_type);
239 if (test_and_set_bit(NFS4CLNT_LAYOUTRECALL, &clp->cl_state))
240 goto out;
241 if (args->cbl_recall_type == RETURN_FILE)
242 res = initiate_file_draining(clp, args);
243 else
244 res = initiate_bulk_draining(clp, args);
245 clear_bit(NFS4CLNT_LAYOUTRECALL, &clp->cl_state);
246out:
247 dprintk("%s returning %i\n", __func__, res);
248 return res;
249
250}
251
f2a62561
FI
252__be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,
253 void *dummy, struct cb_process_state *cps)
254{
43f1b3da
FI
255 u32 res;
256
257 dprintk("%s: -->\n", __func__);
258
259 if (cps->clp)
260 res = do_callback_layoutrecall(cps->clp, args);
261 else
262 res = NFS4ERR_OP_NOT_IN_SESSION;
263
264 dprintk("%s: exit with status = %d\n", __func__, res);
265 return cpu_to_be32(res);
f2a62561
FI
266}
267
36840370
AB
268static void pnfs_recall_all_layouts(struct nfs_client *clp)
269{
270 struct cb_layoutrecallargs args;
271
272 /* Pretend we got a CB_LAYOUTRECALL(ALL) */
273 memset(&args, 0, sizeof(args));
274 args.cbl_recall_type = RETURN_ALL;
275 /* FIXME we ignore errors, what should we do? */
276 do_callback_layoutrecall(clp, &args);
277}
278
1be5683b
ME
279__be32 nfs4_callback_devicenotify(struct cb_devicenotifyargs *args,
280 void *dummy, struct cb_process_state *cps)
281{
282 int i;
283 __be32 res = 0;
284 struct nfs_client *clp = cps->clp;
285 struct nfs_server *server = NULL;
286
287 dprintk("%s: -->\n", __func__);
288
289 if (!clp) {
290 res = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
291 goto out;
292 }
293
294 for (i = 0; i < args->ndevs; i++) {
295 struct cb_devicenotifyitem *dev = &args->devs[i];
296
297 if (!server ||
298 server->pnfs_curr_ld->id != dev->cbd_layout_type) {
299 rcu_read_lock();
300 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
301 if (server->pnfs_curr_ld &&
302 server->pnfs_curr_ld->id == dev->cbd_layout_type) {
303 rcu_read_unlock();
304 goto found;
305 }
306 rcu_read_unlock();
307 dprintk("%s: layout type %u not found\n",
308 __func__, dev->cbd_layout_type);
309 continue;
310 }
311
312 found:
313 if (dev->cbd_notify_type == NOTIFY_DEVICEID4_CHANGE)
314 dprintk("%s: NOTIFY_DEVICEID4_CHANGE not supported, "
315 "deleting instead\n", __func__);
35c8bb54 316 nfs4_delete_deviceid(server->pnfs_curr_ld, clp, &dev->cbd_dev_id);
1be5683b
ME
317 }
318
319out:
320 kfree(args->devs);
321 dprintk("%s: exit with status = %u\n",
322 __func__, be32_to_cpu(res));
323 return res;
324}
325
2597641d
AB
326int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
327{
328 if (delegation == NULL)
329 return 0;
330
94499252 331 if (stateid->stateid.seqid != 0)
2597641d 332 return 0;
94499252
AB
333 if (memcmp(&delegation->stateid.stateid.other,
334 &stateid->stateid.other,
335 NFS4_STATEID_OTHER_SIZE))
2597641d
AB
336 return 0;
337
338 return 1;
339}
340
68f3f901
RL
341/*
342 * Validate the sequenceID sent by the server.
343 * Return success if the sequenceID is one more than what we last saw on
344 * this slot, accounting for wraparound. Increments the slot's sequence.
345 *
4911096f
AA
346 * We don't yet implement a duplicate request cache, instead we set the
347 * back channel ca_maxresponsesize_cached to zero. This is OK for now
68f3f901
RL
348 * since we only currently implement idempotent callbacks anyway.
349 *
350 * We have a single slot backchannel at this time, so we don't bother
351 * checking the used_slots bit array on the table. The lower layer guarantees
352 * a single outstanding callback request at a time.
353 */
9733f0d9 354static __be32
b2f28bd7 355validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
68f3f901
RL
356{
357 struct nfs4_slot *slot;
358
359 dprintk("%s enter. slotid %d seqid %d\n",
b2f28bd7 360 __func__, args->csa_slotid, args->csa_sequenceid);
68f3f901 361
61f2e510 362 if (args->csa_slotid >= NFS41_BC_MAX_CALLBACKS)
68f3f901
RL
363 return htonl(NFS4ERR_BADSLOT);
364
b2f28bd7 365 slot = tbl->slots + args->csa_slotid;
68f3f901
RL
366 dprintk("%s slot table seqid: %d\n", __func__, slot->seq_nr);
367
368 /* Normal */
b2f28bd7 369 if (likely(args->csa_sequenceid == slot->seq_nr + 1)) {
68f3f901 370 slot->seq_nr++;
55a67399 371 goto out_ok;
68f3f901
RL
372 }
373
374 /* Replay */
b2f28bd7 375 if (args->csa_sequenceid == slot->seq_nr) {
4911096f 376 dprintk("%s seqid %d is a replay\n",
b2f28bd7 377 __func__, args->csa_sequenceid);
4911096f
AA
378 /* Signal process_op to set this error on next op */
379 if (args->csa_cachethis == 0)
380 return htonl(NFS4ERR_RETRY_UNCACHED_REP);
381
382 /* The ca_maxresponsesize_cached is 0 with no DRC */
383 else if (args->csa_cachethis == 1)
384 return htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE);
68f3f901
RL
385 }
386
387 /* Wraparound */
b2f28bd7 388 if (args->csa_sequenceid == 1 && (slot->seq_nr + 1) == 0) {
68f3f901 389 slot->seq_nr = 1;
55a67399 390 goto out_ok;
68f3f901
RL
391 }
392
393 /* Misordered request */
394 return htonl(NFS4ERR_SEQ_MISORDERED);
55a67399
TM
395out_ok:
396 tbl->highest_used_slotid = args->csa_slotid;
397 return htonl(NFS4_OK);
68f3f901
RL
398}
399
a7989c3e
MS
400/*
401 * For each referring call triple, check the session's slot table for
402 * a match. If the slot is in use and the sequence numbers match, the
403 * client is still waiting for a response to the original request.
404 */
405static bool referring_call_exists(struct nfs_client *clp,
406 uint32_t nrclists,
407 struct referring_call_list *rclists)
408{
409 bool status = 0;
410 int i, j;
411 struct nfs4_session *session;
412 struct nfs4_slot_table *tbl;
413 struct referring_call_list *rclist;
414 struct referring_call *ref;
415
416 /*
417 * XXX When client trunking is implemented, this becomes
418 * a session lookup from within the loop
419 */
420 session = clp->cl_session;
421 tbl = &session->fc_slot_table;
422
423 for (i = 0; i < nrclists; i++) {
424 rclist = &rclists[i];
425 if (memcmp(session->sess_id.data,
426 rclist->rcl_sessionid.data,
427 NFS4_MAX_SESSIONID_LEN) != 0)
428 continue;
429
430 for (j = 0; j < rclist->rcl_nrefcalls; j++) {
431 ref = &rclist->rcl_refcalls[j];
432
433 dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u "
434 "slotid %u\n", __func__,
435 ((u32 *)&rclist->rcl_sessionid.data)[0],
436 ((u32 *)&rclist->rcl_sessionid.data)[1],
437 ((u32 *)&rclist->rcl_sessionid.data)[2],
438 ((u32 *)&rclist->rcl_sessionid.data)[3],
439 ref->rc_sequenceid, ref->rc_slotid);
440
441 spin_lock(&tbl->slot_tbl_lock);
442 status = (test_bit(ref->rc_slotid, tbl->used_slots) &&
443 tbl->slots[ref->rc_slotid].seq_nr ==
444 ref->rc_sequenceid);
445 spin_unlock(&tbl->slot_tbl_lock);
446 if (status)
447 goto out;
448 }
449 }
450
451out:
452 return status;
453}
454
9733f0d9 455__be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
c36fca52
AA
456 struct cb_sequenceres *res,
457 struct cb_process_state *cps)
d49433e1 458{
55a67399 459 struct nfs4_slot_table *tbl;
68f3f901 460 struct nfs_client *clp;
9733f0d9 461 int i;
778be232 462 __be32 status = htonl(NFS4ERR_BADSESSION);
d49433e1 463
c7add9a9 464 clp = nfs4_find_client_sessionid(cps->net, args->csa_addr, &args->csa_sessionid);
68f3f901
RL
465 if (clp == NULL)
466 goto out;
467
55a67399
TM
468 tbl = &clp->cl_session->bc_slot_table;
469
470 spin_lock(&tbl->slot_tbl_lock);
42acd021
AA
471 /* state manager is resetting the session */
472 if (test_bit(NFS4_SESSION_DRAINING, &clp->cl_session->session_state)) {
55a67399
TM
473 spin_unlock(&tbl->slot_tbl_lock);
474 status = htonl(NFS4ERR_DELAY);
910ac68a
TM
475 /* Return NFS4ERR_BADSESSION if we're draining the session
476 * in order to reset it.
477 */
478 if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
479 status = htonl(NFS4ERR_BADSESSION);
42acd021
AA
480 goto out;
481 }
482
b2f28bd7 483 status = validate_seqid(&clp->cl_session->bc_slot_table, args);
55a67399 484 spin_unlock(&tbl->slot_tbl_lock);
68f3f901 485 if (status)
c36fca52 486 goto out;
68f3f901 487
55a67399
TM
488 cps->slotid = args->csa_slotid;
489
72ce2b3c
MS
490 /*
491 * Check for pending referring calls. If a match is found, a
492 * related callback was received before the response to the original
493 * call.
494 */
495 if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
496 status = htonl(NFS4ERR_DELAY);
c36fca52 497 goto out;
72ce2b3c
MS
498 }
499
d49433e1
BH
500 memcpy(&res->csr_sessionid, &args->csa_sessionid,
501 sizeof(res->csr_sessionid));
502 res->csr_sequenceid = args->csa_sequenceid;
503 res->csr_slotid = args->csa_slotid;
504 res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
505 res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
506
68f3f901 507out:
2c4cdf8f 508 cps->clp = clp; /* put in nfs4_callback_compound */
72ce2b3c
MS
509 for (i = 0; i < args->csa_nrclists; i++)
510 kfree(args->csa_rclists[i].rcl_refcalls);
511 kfree(args->csa_rclists);
512
c36fca52
AA
513 if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) {
514 cps->drc_status = status;
515 status = 0;
516 } else
4911096f 517 res->csr_status = status;
c36fca52 518
4911096f
AA
519 dprintk("%s: exit with status = %d res->csr_status %d\n", __func__,
520 ntohl(status), ntohl(res->csr_status));
521 return status;
d49433e1
BH
522}
523
36840370
AB
524static bool
525validate_bitmap_values(unsigned long mask)
526{
527 return (mask & ~RCA4_TYPE_MASK_ALL) == 0;
528}
529
c36fca52
AA
530__be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
531 struct cb_process_state *cps)
31f09607 532{
9733f0d9 533 __be32 status;
31f09607
AB
534 fmode_t flags = 0;
535
36840370 536 status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
c36fca52 537 if (!cps->clp) /* set in cb_sequence */
31f09607
AB
538 goto out;
539
540 dprintk("NFS: RECALL_ANY callback request from %s\n",
c36fca52 541 rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
31f09607 542
36840370
AB
543 status = cpu_to_be32(NFS4ERR_INVAL);
544 if (!validate_bitmap_values(args->craa_type_mask))
545 goto out;
546
547 status = cpu_to_be32(NFS4_OK);
31f09607
AB
548 if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *)
549 &args->craa_type_mask))
550 flags = FMODE_READ;
551 if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *)
552 &args->craa_type_mask))
553 flags |= FMODE_WRITE;
36840370
AB
554 if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *)
555 &args->craa_type_mask))
556 pnfs_recall_all_layouts(cps->clp);
31f09607 557 if (flags)
c36fca52 558 nfs_expire_all_delegation_types(cps->clp, flags);
31f09607
AB
559out:
560 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
561 return status;
562}
b9efa1b2
AA
563
564/* Reduce the fore channel's max_slots to the target value */
c36fca52
AA
565__be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy,
566 struct cb_process_state *cps)
b9efa1b2 567{
b9efa1b2 568 struct nfs4_slot_table *fc_tbl;
9733f0d9 569 __be32 status;
b9efa1b2
AA
570
571 status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
c36fca52 572 if (!cps->clp) /* set in cb_sequence */
b9efa1b2
AA
573 goto out;
574
575 dprintk("NFS: CB_RECALL_SLOT request from %s target max slots %d\n",
c36fca52 576 rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR),
b9efa1b2
AA
577 args->crsa_target_max_slots);
578
c36fca52 579 fc_tbl = &cps->clp->cl_session->fc_slot_table;
b9efa1b2
AA
580
581 status = htonl(NFS4ERR_BAD_HIGH_SLOT);
bae0ac0e 582 if (args->crsa_target_max_slots > fc_tbl->max_slots ||
b9efa1b2 583 args->crsa_target_max_slots < 1)
c36fca52 584 goto out;
bae0ac0e
AA
585
586 status = htonl(NFS4_OK);
587 if (args->crsa_target_max_slots == fc_tbl->max_slots)
c36fca52 588 goto out;
b9efa1b2
AA
589
590 fc_tbl->target_max_slots = args->crsa_target_max_slots;
c36fca52 591 nfs41_handle_recall_slot(cps->clp);
b9efa1b2
AA
592out:
593 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
594 return status;
595}
d49433e1 596#endif /* CONFIG_NFS_V4_1 */