On 6/11/25 2:56 AM, Christoph Hellwig wrote: > On Tue, Jun 10, 2025 at 02:10:46PM -0400, Chuck Lever wrote: >>> + if (xdr_stream_decode_u32(argp->xdr, &len) < 0) >>> + return nfserr_bad_xdr; >>> + if (!xdr_stream_subsegment(argp->xdr, &lcp->lc_up_layout, len)) >>> return nfserr_bad_xdr; >> >> The layout is effectively an opaque payload at this point, so using >> xdr_stream_subsegment() makes sense to me. > > Btw, when trying to switch XDR to work with bvec backing, > xdr_stream_subsegment has been a very painful primitive. I also don't > really understand what the benefit of it is vs just keeping on decoding > the subsegment normally. That might just be me not understanding the > code, though. XDR subsegments are useful when another layer will be responsible for encoding or decoding the field. Generally a subsegment contains an opaque (an operation in an NFSv4 COMPOUND, a read or write payload, or an RPCGSS_SEC payload that is checksummed or encrypted). For pNFS, the layout metadata has to be skipped over when it is encountered in a generic operation like LAYOUTCOMMIT, but then it is later handled by another layer (the layouttype-specific plug-in, which is part of an "upper layer"). The generic layer has to confirm that the length of the opaque is correct, skip over that length, and then continue marshaling or unmarshaling fields after the opaque. -- Chuck Lever