callback_proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. write_seqcount_begin(&clp->cl_callback_count);
  289. write_seqcount_end(&clp->cl_callback_count);
  290. if (args->cbl_recall_type == RETURN_FILE)
  291. return initiate_file_draining(clp, args);
  292. return initiate_bulk_draining(clp, args);
  293. }
  294. __be32 nfs4_callback_layoutrecall(void *argp, void *resp,
  295. struct cb_process_state *cps)
  296. {
  297. struct cb_layoutrecallargs *args = argp;
  298. u32 res = NFS4ERR_OP_NOT_IN_SESSION;
  299. if (cps->clp)
  300. res = do_callback_layoutrecall(cps->clp, args);
  301. return cpu_to_be32(res);
  302. }
  303. static void pnfs_recall_all_layouts(struct nfs_client *clp)
  304. {
  305. struct cb_layoutrecallargs args;
  306. /* Pretend we got a CB_LAYOUTRECALL(ALL) */
  307. memset(&args, 0, sizeof(args));
  308. args.cbl_recall_type = RETURN_ALL;
  309. /* FIXME we ignore errors, what should we do? */
  310. do_callback_layoutrecall(clp, &args);
  311. }
  312. __be32 nfs4_callback_devicenotify(void *argp, void *resp,
  313. struct cb_process_state *cps)
  314. {
  315. struct cb_devicenotifyargs *args = argp;
  316. int i;
  317. __be32 res = 0;
  318. struct nfs_client *clp = cps->clp;
  319. struct nfs_server *server = NULL;
  320. if (!clp) {
  321. res = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
  322. goto out;
  323. }
  324. for (i = 0; i < args->ndevs; i++) {
  325. struct cb_devicenotifyitem *dev = &args->devs[i];
  326. if (!server ||
  327. server->pnfs_curr_ld->id != dev->cbd_layout_type) {
  328. rcu_read_lock();
  329. list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
  330. if (server->pnfs_curr_ld &&
  331. server->pnfs_curr_ld->id == dev->cbd_layout_type) {
  332. rcu_read_unlock();
  333. goto found;
  334. }
  335. rcu_read_unlock();
  336. continue;
  337. }
  338. found:
  339. nfs4_delete_deviceid(server->pnfs_curr_ld, clp, &dev->cbd_dev_id);
  340. }
  341. out:
  342. kfree(args->devs);
  343. return res;
  344. }
  345. /*
  346. * Validate the sequenceID sent by the server.
  347. * Return success if the sequenceID is one more than what we last saw on
  348. * this slot, accounting for wraparound. Increments the slot's sequence.
  349. *
  350. * We don't yet implement a duplicate request cache, instead we set the
  351. * back channel ca_maxresponsesize_cached to zero. This is OK for now
  352. * since we only currently implement idempotent callbacks anyway.
  353. *
  354. * We have a single slot backchannel at this time, so we don't bother
  355. * checking the used_slots bit array on the table. The lower layer guarantees
  356. * a single outstanding callback request at a time.
  357. */
  358. static __be32
  359. validate_seqid(const struct nfs4_slot_table *tbl, const struct nfs4_slot *slot,
  360. const struct cb_sequenceargs * args)
  361. {
  362. if (args->csa_slotid > tbl->server_highest_slotid)
  363. return htonl(NFS4ERR_BADSLOT);
  364. /* Replay */
  365. if (args->csa_sequenceid == slot->seq_nr) {
  366. if (nfs4_test_locked_slot(tbl, slot->slot_nr))
  367. return htonl(NFS4ERR_DELAY);
  368. /* Signal process_op to set this error on next op */
  369. if (args->csa_cachethis == 0)
  370. return htonl(NFS4ERR_RETRY_UNCACHED_REP);
  371. /* Liar! We never allowed you to set csa_cachethis != 0 */
  372. return htonl(NFS4ERR_SEQ_FALSE_RETRY);
  373. }
  374. /* Wraparound */
  375. if (unlikely(slot->seq_nr == 0xFFFFFFFFU)) {
  376. if (args->csa_sequenceid == 1)
  377. return htonl(NFS4_OK);
  378. } else if (likely(args->csa_sequenceid == slot->seq_nr + 1))
  379. return htonl(NFS4_OK);
  380. /* Misordered request */
  381. return htonl(NFS4ERR_SEQ_MISORDERED);
  382. }
  383. /*
  384. * For each referring call triple, check the session's slot table for
  385. * a match. If the slot is in use and the sequence numbers match, the
  386. * client is still waiting for a response to the original request.
  387. */
  388. static bool referring_call_exists(struct nfs_client *clp,
  389. uint32_t nrclists,
  390. struct referring_call_list *rclists)
  391. {
  392. bool status = false;
  393. int i, j;
  394. struct nfs4_session *session;
  395. struct nfs4_slot_table *tbl;
  396. struct referring_call_list *rclist;
  397. struct referring_call *ref;
  398. /*
  399. * XXX When client trunking is implemented, this becomes
  400. * a session lookup from within the loop
  401. */
  402. session = clp->cl_session;
  403. tbl = &session->fc_slot_table;
  404. for (i = 0; i < nrclists; i++) {
  405. rclist = &rclists[i];
  406. if (memcmp(session->sess_id.data,
  407. rclist->rcl_sessionid.data,
  408. NFS4_MAX_SESSIONID_LEN) != 0)
  409. continue;
  410. for (j = 0; j < rclist->rcl_nrefcalls; j++) {
  411. ref = &rclist->rcl_refcalls[j];
  412. status = nfs4_slot_wait_on_seqid(tbl, ref->rc_slotid,
  413. ref->rc_sequenceid, HZ >> 1) < 0;
  414. if (status)
  415. goto out;
  416. }
  417. }
  418. out:
  419. return status;
  420. }
  421. __be32 nfs4_callback_sequence(void *argp, void *resp,
  422. struct cb_process_state *cps)
  423. {
  424. struct cb_sequenceargs *args = argp;
  425. struct cb_sequenceres *res = resp;
  426. struct nfs4_slot_table *tbl;
  427. struct nfs4_slot *slot;
  428. struct nfs_client *clp;
  429. int i;
  430. __be32 status = htonl(NFS4ERR_BADSESSION);
  431. clp = nfs4_find_client_sessionid(cps->net, args->csa_addr,
  432. &args->csa_sessionid, cps->minorversion);
  433. if (clp == NULL)
  434. goto out;
  435. if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
  436. goto out;
  437. tbl = &clp->cl_session->bc_slot_table;
  438. /* Set up res before grabbing the spinlock */
  439. memcpy(&res->csr_sessionid, &args->csa_sessionid,
  440. sizeof(res->csr_sessionid));
  441. res->csr_sequenceid = args->csa_sequenceid;
  442. res->csr_slotid = args->csa_slotid;
  443. spin_lock(&tbl->slot_tbl_lock);
  444. /* state manager is resetting the session */
  445. if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
  446. status = htonl(NFS4ERR_DELAY);
  447. /* Return NFS4ERR_BADSESSION if we're draining the session
  448. * in order to reset it.
  449. */
  450. if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
  451. status = htonl(NFS4ERR_BADSESSION);
  452. goto out_unlock;
  453. }
  454. status = htonl(NFS4ERR_BADSLOT);
  455. slot = nfs4_lookup_slot(tbl, args->csa_slotid);
  456. if (IS_ERR(slot))
  457. goto out_unlock;
  458. res->csr_highestslotid = tbl->server_highest_slotid;
  459. res->csr_target_highestslotid = tbl->target_highest_slotid;
  460. status = validate_seqid(tbl, slot, args);
  461. if (status)
  462. goto out_unlock;
  463. if (!nfs4_try_to_lock_slot(tbl, slot)) {
  464. status = htonl(NFS4ERR_DELAY);
  465. goto out_unlock;
  466. }
  467. cps->slot = slot;
  468. /* The ca_maxresponsesize_cached is 0 with no DRC */
  469. if (args->csa_cachethis != 0) {
  470. status = htonl(NFS4ERR_REP_TOO_BIG_TO_CACHE);
  471. goto out_unlock;
  472. }
  473. /*
  474. * Check for pending referring calls. If a match is found, a
  475. * related callback was received before the response to the original
  476. * call.
  477. */
  478. if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
  479. status = htonl(NFS4ERR_DELAY);
  480. goto out_unlock;
  481. }
  482. /*
  483. * RFC5661 20.9.3
  484. * If CB_SEQUENCE returns an error, then the state of the slot
  485. * (sequence ID, cached reply) MUST NOT change.
  486. */
  487. slot->seq_nr = args->csa_sequenceid;
  488. out_unlock:
  489. spin_unlock(&tbl->slot_tbl_lock);
  490. out:
  491. cps->clp = clp; /* put in nfs4_callback_compound */
  492. for (i = 0; i < args->csa_nrclists; i++)
  493. kfree(args->csa_rclists[i].rcl_refcalls);
  494. kfree(args->csa_rclists);
  495. if (status == htonl(NFS4ERR_RETRY_UNCACHED_REP)) {
  496. cps->drc_status = status;
  497. status = 0;
  498. } else
  499. res->csr_status = status;
  500. trace_nfs4_cb_sequence(args, res, status);
  501. return status;
  502. }
  503. static bool
  504. validate_bitmap_values(unsigned int mask)
  505. {
  506. return (mask & ~RCA4_TYPE_MASK_ALL) == 0;
  507. }
  508. __be32 nfs4_callback_recallany(void *argp, void *resp,
  509. struct cb_process_state *cps)
  510. {
  511. struct cb_recallanyargs *args = argp;
  512. __be32 status;
  513. fmode_t flags = 0;
  514. status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
  515. if (!cps->clp) /* set in cb_sequence */
  516. goto out;
  517. dprintk_rcu("NFS: RECALL_ANY callback request from %s\n",
  518. rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
  519. status = cpu_to_be32(NFS4ERR_INVAL);
  520. if (!validate_bitmap_values(args->craa_type_mask))
  521. goto out;
  522. status = cpu_to_be32(NFS4_OK);
  523. if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_RDATA_DLG))
  524. flags = FMODE_READ;
  525. if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_WDATA_DLG))
  526. flags |= FMODE_WRITE;
  527. if (flags)
  528. nfs_expire_unused_delegation_types(cps->clp, flags);
  529. if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_FILE_LAYOUT))
  530. pnfs_recall_all_layouts(cps->clp);
  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 */