callback_proc.c 17 KB

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