callback_proc.c 17 KB

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