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

NFS CB_OFFLOAD xdr

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Olga Kornievskaia and committed by
Anna Schumaker
5178a125 46483c2e

+98 -1
+12
fs/nfs/callback.h
··· 184 184 extern __be32 nfs4_callback_notify_lock(void *argp, void *resp, 185 185 struct cb_process_state *cps); 186 186 #endif /* CONFIG_NFS_V4_1 */ 187 + #ifdef CONFIG_NFS_V4_2 188 + struct cb_offloadargs { 189 + struct nfs_fh coa_fh; 190 + nfs4_stateid coa_stateid; 191 + uint32_t error; 192 + uint64_t wr_count; 193 + struct nfs_writeverf wr_writeverf; 194 + }; 195 + 196 + extern __be32 nfs4_callback_offload(void *args, void *dummy, 197 + struct cb_process_state *cps); 198 + #endif /* CONFIG_NFS_V4_2 */ 187 199 extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *); 188 200 extern __be32 nfs4_callback_getattr(void *argp, void *resp, 189 201 struct cb_process_state *cps);
+7
fs/nfs/callback_proc.c
··· 661 661 return htonl(NFS4_OK); 662 662 } 663 663 #endif /* CONFIG_NFS_V4_1 */ 664 + #ifdef CONFIG_NFS_V4_2 665 + __be32 nfs4_callback_offload(void *args, void *dummy, 666 + struct cb_process_state *cps) 667 + { 668 + return 0; 669 + } 670 + #endif /* CONFIG_NFS_V4_2 */
+79 -1
fs/nfs/callback_xdr.c
··· 38 38 #define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 39 39 #define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 40 40 #endif /* CONFIG_NFS_V4_1 */ 41 + #ifdef CONFIG_NFS_V4_2 42 + #define CB_OP_OFFLOAD_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 43 + #endif /* CONFIG_NFS_V4_2 */ 41 44 42 45 #define NFSDBG_FACILITY NFSDBG_CALLBACK 43 46 ··· 530 527 } 531 528 532 529 #endif /* CONFIG_NFS_V4_1 */ 530 + #ifdef CONFIG_NFS_V4_2 531 + static __be32 decode_write_response(struct xdr_stream *xdr, 532 + struct cb_offloadargs *args) 533 + { 534 + __be32 *p; 533 535 536 + /* skip the always zero field */ 537 + p = read_buf(xdr, 4); 538 + if (unlikely(!p)) 539 + goto out; 540 + p++; 541 + 542 + /* decode count, stable_how, verifier */ 543 + p = xdr_inline_decode(xdr, 8 + 4); 544 + if (unlikely(!p)) 545 + goto out; 546 + p = xdr_decode_hyper(p, &args->wr_count); 547 + args->wr_writeverf.committed = be32_to_cpup(p); 548 + p = xdr_inline_decode(xdr, NFS4_VERIFIER_SIZE); 549 + if (likely(p)) { 550 + memcpy(&args->wr_writeverf.verifier.data[0], p, 551 + NFS4_VERIFIER_SIZE); 552 + return 0; 553 + } 554 + out: 555 + return htonl(NFS4ERR_RESOURCE); 556 + } 557 + 558 + static __be32 decode_offload_args(struct svc_rqst *rqstp, 559 + struct xdr_stream *xdr, 560 + void *data) 561 + { 562 + struct cb_offloadargs *args = data; 563 + __be32 *p; 564 + __be32 status; 565 + 566 + /* decode fh */ 567 + status = decode_fh(xdr, &args->coa_fh); 568 + if (unlikely(status != 0)) 569 + return status; 570 + 571 + /* decode stateid */ 572 + status = decode_stateid(xdr, &args->coa_stateid); 573 + if (unlikely(status != 0)) 574 + return status; 575 + 576 + /* decode status */ 577 + p = read_buf(xdr, 4); 578 + if (unlikely(!p)) 579 + goto out; 580 + args->error = ntohl(*p++); 581 + if (!args->error) { 582 + status = decode_write_response(xdr, args); 583 + if (unlikely(status != 0)) 584 + return status; 585 + } else { 586 + p = xdr_inline_decode(xdr, 8); 587 + if (unlikely(!p)) 588 + goto out; 589 + p = xdr_decode_hyper(p, &args->wr_count); 590 + } 591 + return 0; 592 + out: 593 + return htonl(NFS4ERR_RESOURCE); 594 + } 595 + #endif /* CONFIG_NFS_V4_2 */ 534 596 static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 535 597 { 536 598 if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0)) ··· 841 773 if (status != htonl(NFS4ERR_OP_ILLEGAL)) 842 774 return status; 843 775 844 - if (op_nr == OP_CB_OFFLOAD) 776 + if (op_nr == OP_CB_OFFLOAD) { 777 + *op = &callback_ops[op_nr]; 778 + return htonl(NFS_OK); 779 + } else 845 780 return htonl(NFS4ERR_NOTSUPP); 846 781 return htonl(NFS4ERR_OP_ILLEGAL); 847 782 } ··· 1045 974 .res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ, 1046 975 }, 1047 976 #endif /* CONFIG_NFS_V4_1 */ 977 + #ifdef CONFIG_NFS_V4_2 978 + [OP_CB_OFFLOAD] = { 979 + .process_op = nfs4_callback_offload, 980 + .decode_args = decode_offload_args, 981 + .res_maxsize = CB_OP_OFFLOAD_RES_MAXSZ, 982 + }, 983 + #endif /* CONFIG_NFS_V4_2 */ 1048 984 }; 1049 985 1050 986 /*