callback_proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * linux/fs/nfs/callback_proc.c
  3. *
  4. * Copyright (C) 2004 Trond Myklebust
  5. *
  6. * NFSv4 callback procedures
  7. */
  8. #include <linux/nfs4.h>
  9. #include <linux/nfs_fs.h>
  10. #include <linux/slab.h>
  11. #include <linux/rcupdate.h>
  12. #include "nfs4_fs.h"
  13. #include "callback.h"
  14. #include "delegation.h"
  15. #include "internal.h"
  16. #include "pnfs.h"
  17. #include "nfs4session.h"
  18. #include "nfs4trace.h"
  19. #define NFSDBG_FACILITY NFSDBG_CALLBACK
  20. __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
  21. struct cb_getattrres *res,
  22. struct cb_process_state *cps)
  23. {
  24. struct nfs_delegation *delegation;
  25. struct nfs_inode *nfsi;
  26. struct inode *inode;
  27. res->status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
  28. if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */
  29. goto out;
  30. res->bitmap[0] = res->bitmap[1] = 0;
  31. res->status = htonl(NFS4ERR_BADHANDLE);
  32. dprintk_rcu("NFS: GETATTR callback request from %s\n",
  33. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
  34. inode = nfs_delegation_find_inode(cps->clp, &args->fh);
  35. if (inode == NULL) {
  36. trace_nfs4_cb_getattr(cps->clp, &args->fh, NULL,
  37. -ntohl(res->status));
  38. goto out;
  39. }
  40. nfsi = NFS_I(inode);
  41. rcu_read_lock();
  42. delegation = rcu_dereference(nfsi->delegation);
  43. if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0)
  44. goto out_iput;
  45. res->size = i_size_read(inode);
  46. res->change_attr = delegation->change_attr;
  47. if (nfsi->nrequests != 0)
  48. res->change_attr++;
  49. res->ctime = inode->i_ctime;
  50. res->mtime = inode->i_mtime;
  51. res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
  52. args->bitmap[0];
  53. res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) &
  54. args->bitmap[1];
  55. res->status = 0;
  56. out_iput:
  57. rcu_read_unlock();
  58. trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status));
  59. iput(inode);
  60. out:
  61. dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
  62. return res->status;
  63. }
  64. __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
  65. struct cb_process_state *cps)
  66. {
  67. struct inode *inode;
  68. __be32 res;
  69. res = htonl(NFS4ERR_OP_NOT_IN_SESSION);
  70. if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */
  71. goto out;
  72. dprintk_rcu("NFS: RECALL callback request from %s\n",
  73. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
  74. res = htonl(NFS4ERR_BADHANDLE);
  75. inode = nfs_delegation_find_inode(cps->clp, &args->fh);
  76. if (inode == NULL) {
  77. trace_nfs4_cb_recall(cps->clp, &args->fh, NULL,
  78. &args->stateid, -ntohl(res));
  79. goto out;
  80. }
  81. /* Set up a helper thread to actually return the delegation */
  82. switch (nfs_async_inode_return_delegation(inode, &args->stateid)) {
  83. case 0:
  84. res = 0;
  85. break;
  86. case -ENOENT:
  87. res = htonl(NFS4ERR_BAD_STATEID);
  88. break;
  89. default:
  90. res = htonl(NFS4ERR_RESOURCE);
  91. }
  92. trace_nfs4_cb_recall(cps->clp, &args->fh, inode,
  93. &args->stateid, -ntohl(res));
  94. iput(inode);
  95. out:
  96. dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
  97. return res;
  98. }
  99. #if defined(CONFIG_NFS_V4_1)
  100. /*
  101. * Lookup a layout by filehandle.
  102. *
  103. * Note: gets a refcount on the layout hdr and on its respective inode.
  104. * Caller must put the layout hdr and the inode.
  105. *
  106. * TODO: keep track of all layouts (and delegations) in a hash table
  107. * hashed by filehandle.
  108. */
  109. static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
  110. struct nfs_fh *fh)
  111. {
  112. struct nfs_server *server;
  113. struct nfs_inode *nfsi;
  114. struct inode *ino;
  115. struct pnfs_layout_hdr *lo;
  116. restart:
  117. list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
  118. list_for_each_entry(lo, &server->layouts, plh_layouts) {
  119. nfsi = NFS_I(lo->plh_inode);
  120. if (nfs_compare_fh(fh, &nfsi->fh))
  121. continue;
  122. if (nfsi->layout != lo)
  123. continue;
  124. ino = igrab(lo->plh_inode);
  125. if (!ino)
  126. break;
  127. spin_lock(&ino->i_lock);
  128. /* Is this layout in the process of being freed? */
  129. if (nfsi->layout != lo) {
  130. spin_unlock(&ino->i_lock);
  131. iput(ino);
  132. goto restart;
  133. }
  134. pnfs_get_layout_hdr(lo);
  135. spin_unlock(&ino->i_lock);
  136. return lo;
  137. }
  138. }
  139. return NULL;
  140. }
  141. static struct pnfs_layout_hdr * get_layout_by_fh(struct nfs_client *clp,
  142. struct nfs_fh *fh)
  143. {
  144. struct pnfs_layout_hdr *lo;
  145. spin_lock(&clp->cl_lock);
  146. rcu_read_lock();
  147. lo = get_layout_by_fh_locked(clp, fh);
  148. rcu_read_unlock();
  149. spin_unlock(&clp->cl_lock);
  150. return lo;
  151. }
  152. /*
  153. * Enforce RFC5661 section 12.5.5.2.1. (Layout Recall and Return Sequencing)
  154. */
  155. static u32 pnfs_check_callback_stateid(struct pnfs_layout_hdr *lo,
  156. const nfs4_stateid *new)
  157. {
  158. u32 oldseq, newseq;
  159. /* Is the stateid still not initialised? */
  160. if (!pnfs_layout_is_valid(lo))
  161. return NFS4ERR_DELAY;
  162. /* Mismatched stateid? */
  163. if (!nfs4_stateid_match_other(&lo->plh_stateid, new))
  164. return NFS4ERR_BAD_STATEID;
  165. newseq = be32_to_cpu(new->seqid);
  166. /* Are we already in a layout recall situation? */
  167. if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) &&
  168. lo->plh_return_seq != 0) {
  169. if (newseq < lo->plh_return_seq)
  170. return NFS4ERR_OLD_STATEID;
  171. if (newseq > lo->plh_return_seq)
  172. return NFS4ERR_DELAY;
  173. goto out;
  174. }
  175. /* Check that the stateid matches what we think it should be. */
  176. oldseq = be32_to_cpu(lo->plh_stateid.seqid);
  177. if (newseq > oldseq + 1)
  178. return NFS4ERR_DELAY;
  179. /* Crazy server! */
  180. if (newseq <= oldseq)
  181. return NFS4ERR_OLD_STATEID;
  182. out:
  183. return NFS_OK;
  184. }
  185. static u32 initiate_file_draining(struct nfs_client *clp,
  186. struct cb_layoutrecallargs *args)
  187. {
  188. struct inode *ino;
  189. struct pnfs_layout_hdr *lo;
  190. u32 rv = NFS4ERR_NOMATCHING_LAYOUT;
  191. LIST_HEAD(free_me_list);
  192. lo = get_layout_by_fh(clp, &args->cbl_fh);
  193. if (!lo) {
  194. trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, NULL,
  195. &args->cbl_stateid, -rv);
  196. goto out;
  197. }
  198. ino = lo->plh_inode;
  199. pnfs_layoutcommit_inode(ino, false);
  200. spin_lock(&ino->i_lock);
  201. rv = pnfs_check_callback_stateid(lo, &args->cbl_stateid);
  202. if (rv != NFS_OK)
  203. goto unlock;
  204. pnfs_set_layout_stateid(lo, &args->cbl_stateid, true);
  205. /*
  206. * Enforce RFC5661 Section 12.5.5.2.1.5 (Bulk Recall and Return)
  207. */
  208. if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) {
  209. rv = NFS4ERR_DELAY;
  210. goto unlock;
  211. }
  212. if (pnfs_mark_matching_lsegs_return(lo, &free_me_list,
  213. &args->cbl_range,
  214. be32_to_cpu(args->cbl_stateid.seqid))) {
  215. rv = NFS4_OK;
  216. goto unlock;
  217. }
  218. /* Embrace your forgetfulness! */
  219. rv = NFS4ERR_NOMATCHING_LAYOUT;
  220. if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
  221. NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo,
  222. &args->cbl_range);
  223. }
  224. unlock:
  225. spin_unlock(&ino->i_lock);
  226. pnfs_free_lseg_list(&free_me_list);
  227. /* Free all lsegs that are attached to commit buckets */
  228. nfs_commit_inode(ino, 0);
  229. pnfs_put_layout_hdr(lo);
  230. trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, ino,
  231. &args->cbl_stateid, -rv);
  232. iput(ino);
  233. out:
  234. return rv;
  235. }
  236. static u32 initiate_bulk_draining(struct nfs_client *clp,
  237. struct cb_layoutrecallargs *args)
  238. {
  239. int stat;
  240. if (args->cbl_recall_type == RETURN_FSID)
  241. stat = pnfs_destroy_layouts_byfsid(clp, &args->cbl_fsid, true);
  242. else
  243. stat = pnfs_destroy_layouts_byclid(clp, true);
  244. if (stat != 0)
  245. return NFS4ERR_DELAY;
  246. return NFS4ERR_NOMATCHING_LAYOUT;
  247. }
  248. static u32 do_callback_layoutrecall(struct nfs_client *clp,
  249. struct cb_layoutrecallargs *args)
  250. {
  251. u32 res;
  252. dprintk("%s enter, type=%i\n", __func__, args->cbl_recall_type);
  253. if (args->cbl_recall_type == RETURN_FILE)
  254. res = initiate_file_draining(clp, args);
  255. else
  256. res = initiate_bulk_draining(clp, args);
  257. dprintk("%s returning %i\n", __func__, res);
  258. return res;
  259. }
  260. __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args,
  261. void *dummy, struct cb_process_state *cps)
  262. {
  263. u32 res;
  264. dprintk("%s: -->\n", __func__);
  265. if (cps->clp)
  266. res = do_callback_layoutrecall(cps->clp, args);
  267. else
  268. res = NFS4ERR_OP_NOT_IN_SESSION;
  269. dprintk("%s: exit with status = %d\n", __func__, res);
  270. return cpu_to_be32(res);
  271. }
  272. static void pnfs_recall_all_layouts(struct nfs_client *clp)
  273. {
  274. struct cb_layoutrecallargs args;
  275. /* Pretend we got a CB_LAYOUTRECALL(ALL) */
  276. memset(&args, 0, sizeof(args));
  277. args.cbl_recall_type = RETURN_ALL;
  278. /* FIXME we ignore errors, what should we do? */
  279. do_callback_layoutrecall(clp, &args);
  280. }
  281. __be32 nfs4_callback_devicenotify(struct cb_devicenotifyargs *args,
  282. void *dummy, struct cb_process_state *cps)
  283. {
  284. int i;
  285. __be32 res = 0;
  286. struct nfs_client *clp = cps->clp;
  287. struct nfs_server *server = NULL;
  288. dprintk("%s: -->\n", __func__);
  289. if (!clp) {
  290. res = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
  291. goto out;
  292. }
  293. for (i = 0; i < args->ndevs; i++) {
  294. struct cb_devicenotifyitem *dev = &args->devs[i];
  295. if (!server ||
  296. server->pnfs_curr_ld->id != dev->cbd_layout_type) {
  297. rcu_read_lock();
  298. list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
  299. if (server->pnfs_curr_ld &&
  300. server->pnfs_curr_ld->id == dev->cbd_layout_type) {
  301. rcu_read_unlock();
  302. goto found;
  303. }
  304. rcu_read_unlock();
  305. dprintk("%s: layout type %u not found\n",
  306. __func__, dev->cbd_layout_type);
  307. continue;
  308. }
  309. found:
  310. nfs4_delete_deviceid(server->pnfs_curr_ld, clp, &dev->cbd_dev_id);
  311. }
  312. out:
  313. kfree(args->devs);
  314. dprintk("%s: exit with status = %u\n",
  315. __func__, be32_to_cpu(res));
  316. return res;
  317. }
  318. /*
  319. * Validate the sequenceID sent by the server.
  320. * Return success if the sequenceID is one more than what we last saw on
  321. * this slot, accounting for wraparound. Increments the slot's sequence.
  322. *
  323. * We don't yet implement a duplicate request cache, instead we set the
  324. * back channel ca_maxresponsesize_cached to zero. This is OK for now
  325. * since we only currently implement idempotent callbacks anyway.
  326. *
  327. * We have a single slot backchannel at this time, so we don't bother
  328. * checking the used_slots bit array on the table. The lower layer guarantees
  329. * a single outstanding callback request at a time.
  330. */
  331. static __be32
  332. validate_seqid(const struct nfs4_slot_table *tbl, const struct nfs4_slot *slot,
  333. const struct cb_sequenceargs * args)
  334. {
  335. dprintk("%s enter. slotid %u seqid %u, slot table seqid: %u\n",
  336. __func__, args->csa_slotid, args->csa_sequenceid, slot->seq_nr);
  337. if (args->csa_slotid > tbl->server_highest_slotid)
  338. return htonl(NFS4ERR_BADSLOT);
  339. /* Replay */
  340. if (args->csa_sequenceid == slot->seq_nr) {
  341. dprintk("%s seqid %u is a replay\n",
  342. __func__, args->csa_sequenceid);
  343. if (nfs4_test_locked_slot(tbl, slot->slot_nr))
  344. return htonl(NFS4ERR_DELAY);
  345. /* Signal process_op to set this error on next op */
  346. if (args->csa_cachethis == 0)
  347. return htonl(NFS4ERR_RETRY_UNCACHED_REP);
  348. /* Liar! We never allowed you to set csa_cachethis != 0 */
  349. return htonl(NFS4ERR_SEQ_FALSE_RETRY);
  350. }
  351. /* Note: wraparound relies on seq_nr being of type u32 */
  352. if (likely(args->csa_sequenceid == slot->seq_nr + 1))
  353. return htonl(NFS4_OK);
  354. /* Misordered request */
  355. return htonl(NFS4ERR_SEQ_MISORDERED);
  356. }
  357. /*
  358. * For each referring call triple, check the session's slot table for
  359. * a match. If the slot is in use and the sequence numbers match, the
  360. * client is still waiting for a response to the original request.
  361. */
  362. static bool referring_call_exists(struct nfs_client *clp,
  363. uint32_t nrclists,
  364. struct referring_call_list *rclists)
  365. {
  366. bool status = 0;
  367. int i, j;
  368. struct nfs4_session *session;
  369. struct nfs4_slot_table *tbl;
  370. struct referring_call_list *rclist;
  371. struct referring_call *ref;
  372. /*
  373. * XXX When client trunking is implemented, this becomes
  374. * a session lookup from within the loop
  375. */
  376. session = clp->cl_session;
  377. tbl = &session->fc_slot_table;
  378. for (i = 0; i < nrclists; i++) {
  379. rclist = &rclists[i];
  380. if (memcmp(session->sess_id.data,
  381. rclist->rcl_sessionid.data,
  382. NFS4_MAX_SESSIONID_LEN) != 0)
  383. continue;
  384. for (j = 0; j < rclist->rcl_nrefcalls; j++) {
  385. ref = &rclist->rcl_refcalls[j];
  386. dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u "
  387. "slotid %u\n", __func__,
  388. ((u32 *)&rclist->rcl_sessionid.data)[0],
  389. ((u32 *)&rclist->rcl_sessionid.data)[1],
  390. ((u32 *)&rclist->rcl_sessionid.data)[2],
  391. ((u32 *)&rclist->rcl_sessionid.data)[3],
  392. ref->rc_sequenceid, ref->rc_slotid);
  393. status = nfs4_slot_wait_on_seqid(tbl, ref->rc_slotid,
  394. ref->rc_sequenceid, HZ >> 1) < 0;
  395. if (status)
  396. goto out;
  397. }
  398. }
  399. out:
  400. return status;
  401. }
  402. __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
  403. struct cb_sequenceres *res,
  404. struct cb_process_state *cps)
  405. {
  406. struct nfs4_slot_table *tbl;
  407. struct nfs4_slot *slot;
  408. struct nfs_client *clp;
  409. int i;
  410. __be32 status = htonl(NFS4ERR_BADSESSION);
  411. clp = nfs4_find_client_sessionid(cps->net, args->csa_addr,
  412. &args->csa_sessionid, cps->minorversion);
  413. if (clp == NULL)
  414. goto out;
  415. if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
  416. goto out;
  417. tbl = &clp->cl_session->bc_slot_table;
  418. /* Set up res before grabbing the spinlock */
  419. memcpy(&res->csr_sessionid, &args->csa_sessionid,
  420. sizeof(res->csr_sessionid));
  421. res->csr_sequenceid = args->csa_sequenceid;
  422. res->csr_slotid = args->csa_slotid;
  423. spin_lock(&tbl->slot_tbl_lock);
  424. /* state manager is resetting the session */
  425. if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
  426. status = htonl(NFS4ERR_DELAY);
  427. /* Return NFS4ERR_BADSESSION if we're draining the session
  428. * in order to reset it.
  429. */
  430. if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
  431. status = htonl(NFS4ERR_BADSESSION);
  432. goto out_unlock;
  433. }
  434. status = htonl(NFS4ERR_BADSLOT);
  435. slot = nfs4_lookup_slot(tbl, args->csa_slotid);
  436. if (IS_ERR(slot))
  437. goto out_unlock;
  438. res->csr_highestslotid = tbl->server_highest_slotid;
  439. res->csr_target_highestslotid = tbl->target_highest_slotid;
  440. status = validate_seqid(tbl, slot, args);
  441. if (status)
  442. goto out_unlock;
  443. if (!nfs4_try_to_lock_slot(tbl, slot)) {
  444. status = htonl(NFS4ERR_DELAY);
  445. goto out_unlock;
  446. }
  447. cps->slot = slot;
  448. /* The ca_maxresponsesize_cached is 0 with no DRC */
  449. if (args->csa_cachethis != 0) {
  450. status = htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE);
  451. goto out_unlock;
  452. }
  453. /*
  454. * Check for pending referring calls. If a match is found, a
  455. * related callback was received before the response to the original
  456. * call.
  457. */
  458. if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
  459. status = htonl(NFS4ERR_DELAY);
  460. goto out_unlock;
  461. }
  462. /*
  463. * RFC5661 20.9.3
  464. * If CB_SEQUENCE returns an error, then the state of the slot
  465. * (sequence ID, cached reply) MUST NOT change.
  466. */
  467. slot->seq_nr = args->csa_sequenceid;
  468. out_unlock:
  469. spin_unlock(&tbl->slot_tbl_lock);
  470. out:
  471. cps->clp = clp; /* put in nfs4_callback_compound */
  472. for (i = 0; i < args->csa_nrclists; i++)
  473. kfree(args->csa_rclists[i].rcl_refcalls);
  474. kfree(args->csa_rclists);
  475. if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) {
  476. cps->drc_status = status;
  477. status = 0;
  478. } else
  479. res->csr_status = status;
  480. trace_nfs4_cb_sequence(args, res, status);
  481. dprintk("%s: exit with status = %d res->csr_status %d\n", __func__,
  482. ntohl(status), ntohl(res->csr_status));
  483. return status;
  484. }
  485. static bool
  486. validate_bitmap_values(unsigned long mask)
  487. {
  488. return (mask & ~RCA4_TYPE_MASK_ALL) == 0;
  489. }
  490. __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy,
  491. struct cb_process_state *cps)
  492. {
  493. __be32 status;
  494. fmode_t flags = 0;
  495. status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
  496. if (!cps->clp) /* set in cb_sequence */
  497. goto out;
  498. dprintk_rcu("NFS: RECALL_ANY callback request from %s\n",
  499. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
  500. status = cpu_to_be32(NFS4ERR_INVAL);
  501. if (!validate_bitmap_values(args->craa_type_mask))
  502. goto out;
  503. status = cpu_to_be32(NFS4_OK);
  504. if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *)
  505. &args->craa_type_mask))
  506. flags = FMODE_READ;
  507. if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *)
  508. &args->craa_type_mask))
  509. flags |= FMODE_WRITE;
  510. if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *)
  511. &args->craa_type_mask))
  512. pnfs_recall_all_layouts(cps->clp);
  513. if (flags)
  514. nfs_expire_unused_delegation_types(cps->clp, flags);
  515. out:
  516. dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
  517. return status;
  518. }
  519. /* Reduce the fore channel's max_slots to the target value */
  520. __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy,
  521. struct cb_process_state *cps)
  522. {
  523. struct nfs4_slot_table *fc_tbl;
  524. __be32 status;
  525. status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
  526. if (!cps->clp) /* set in cb_sequence */
  527. goto out;
  528. dprintk_rcu("NFS: CB_RECALL_SLOT request from %s target highest slotid %u\n",
  529. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR),
  530. args->crsa_target_highest_slotid);
  531. fc_tbl = &cps->clp->cl_session->fc_slot_table;
  532. status = htonl(NFS4_OK);
  533. nfs41_set_target_slotid(fc_tbl, args->crsa_target_highest_slotid);
  534. nfs41_notify_server(cps->clp);
  535. out:
  536. dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
  537. return status;
  538. }
  539. __be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args, void *dummy,
  540. struct cb_process_state *cps)
  541. {
  542. if (!cps->clp) /* set in cb_sequence */
  543. return htonl(NFS4ERR_OP_NOT_IN_SESSION);
  544. dprintk_rcu("NFS: CB_NOTIFY_LOCK request from %s\n",
  545. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
  546. /* Don't wake anybody if the string looked bogus */
  547. if (args->cbnl_valid)
  548. __wake_up(&cps->clp->cl_lock_waitq, TASK_NORMAL, 0, args);
  549. return htonl(NFS4_OK);
  550. }
  551. #endif /* CONFIG_NFS_V4_1 */