Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSD: add support for sending CB_RECALL_ANY

Add XDR encode and decode function for CB_RECALL_ANY.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Dai Ngo and committed by
Chuck Lever
3959066b a1049eb4

+84
+72
fs/nfsd/nfs4callback.c
··· 76 76 * 1 Protocol" 77 77 */ 78 78 79 + static void encode_uint32(struct xdr_stream *xdr, u32 n) 80 + { 81 + WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0); 82 + } 83 + 84 + static void encode_bitmap4(struct xdr_stream *xdr, const __u32 *bitmap, 85 + size_t len) 86 + { 87 + WARN_ON_ONCE(xdr_stream_encode_uint32_array(xdr, bitmap, len) < 0); 88 + } 89 + 79 90 /* 80 91 * nfs_cb_opnum4 81 92 * ··· 340 329 } 341 330 342 331 /* 332 + * CB_RECALLANY4args 333 + * 334 + * struct CB_RECALLANY4args { 335 + * uint32_t craa_objects_to_keep; 336 + * bitmap4 craa_type_mask; 337 + * }; 338 + */ 339 + static void 340 + encode_cb_recallany4args(struct xdr_stream *xdr, 341 + struct nfs4_cb_compound_hdr *hdr, struct nfsd4_cb_recall_any *ra) 342 + { 343 + encode_nfs_cb_opnum4(xdr, OP_CB_RECALL_ANY); 344 + encode_uint32(xdr, ra->ra_keep); 345 + encode_bitmap4(xdr, ra->ra_bmval, ARRAY_SIZE(ra->ra_bmval)); 346 + hdr->nops++; 347 + } 348 + 349 + /* 343 350 * CB_SEQUENCE4args 344 351 * 345 352 * struct CB_SEQUENCE4args { ··· 511 482 encode_cb_nops(&hdr); 512 483 } 513 484 485 + /* 486 + * 20.6. Operation 8: CB_RECALL_ANY - Keep Any N Recallable Objects 487 + */ 488 + static void 489 + nfs4_xdr_enc_cb_recall_any(struct rpc_rqst *req, 490 + struct xdr_stream *xdr, const void *data) 491 + { 492 + const struct nfsd4_callback *cb = data; 493 + struct nfsd4_cb_recall_any *ra; 494 + struct nfs4_cb_compound_hdr hdr = { 495 + .ident = cb->cb_clp->cl_cb_ident, 496 + .minorversion = cb->cb_clp->cl_minorversion, 497 + }; 498 + 499 + ra = container_of(cb, struct nfsd4_cb_recall_any, ra_cb); 500 + encode_cb_compound4args(xdr, &hdr); 501 + encode_cb_sequence4args(xdr, cb, &hdr); 502 + encode_cb_recallany4args(xdr, &hdr, ra); 503 + encode_cb_nops(&hdr); 504 + } 514 505 515 506 /* 516 507 * NFSv4.0 and NFSv4.1 XDR decode functions ··· 567 518 return status; 568 519 569 520 return decode_cb_op_status(xdr, OP_CB_RECALL, &cb->cb_status); 521 + } 522 + 523 + /* 524 + * 20.6. Operation 8: CB_RECALL_ANY - Keep Any N Recallable Objects 525 + */ 526 + static int 527 + nfs4_xdr_dec_cb_recall_any(struct rpc_rqst *rqstp, 528 + struct xdr_stream *xdr, 529 + void *data) 530 + { 531 + struct nfsd4_callback *cb = data; 532 + struct nfs4_cb_compound_hdr hdr; 533 + int status; 534 + 535 + status = decode_cb_compound4res(xdr, &hdr); 536 + if (unlikely(status)) 537 + return status; 538 + status = decode_cb_sequence4res(xdr, cb); 539 + if (unlikely(status || cb->cb_seq_status)) 540 + return status; 541 + status = decode_cb_op_status(xdr, OP_CB_RECALL_ANY, &cb->cb_status); 542 + return status; 570 543 } 571 544 572 545 #ifdef CONFIG_NFSD_PNFS ··· 854 783 #endif 855 784 PROC(CB_NOTIFY_LOCK, COMPOUND, cb_notify_lock, cb_notify_lock), 856 785 PROC(CB_OFFLOAD, COMPOUND, cb_offload, cb_offload), 786 + PROC(CB_RECALL_ANY, COMPOUND, cb_recall_any, cb_recall_any), 857 787 }; 858 788 859 789 static unsigned int nfs4_cb_counts[ARRAY_SIZE(nfs4_cb_procedures)];
+1
fs/nfsd/state.h
··· 636 636 NFSPROC4_CLNT_CB_OFFLOAD, 637 637 NFSPROC4_CLNT_CB_SEQUENCE, 638 638 NFSPROC4_CLNT_CB_NOTIFY_LOCK, 639 + NFSPROC4_CLNT_CB_RECALL_ANY, 639 640 }; 640 641 641 642 /* Returns true iff a is later than b: */
+5
fs/nfsd/xdr4.h
··· 896 896 union nfsd4_op_u *); 897 897 }; 898 898 899 + struct nfsd4_cb_recall_any { 900 + struct nfsd4_callback ra_cb; 901 + u32 ra_keep; 902 + u32 ra_bmval[1]; 903 + }; 899 904 900 905 #endif
+6
fs/nfsd/xdr4cb.h
··· 48 48 #define NFS4_dec_cb_offload_sz (cb_compound_dec_hdr_sz + \ 49 49 cb_sequence_dec_sz + \ 50 50 op_dec_sz) 51 + #define NFS4_enc_cb_recall_any_sz (cb_compound_enc_hdr_sz + \ 52 + cb_sequence_enc_sz + \ 53 + 1 + 1 + 1) 54 + #define NFS4_dec_cb_recall_any_sz (cb_compound_dec_hdr_sz + \ 55 + cb_sequence_dec_sz + \ 56 + op_dec_sz)