@@ -5079,32 +5079,56 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr,
50795079#endif /* CONFIG_NFSD_PNFS */
50805080
50815081static __be32
5082- nfsd42_encode_write_res (struct nfsd4_compoundres * resp ,
5083- struct nfsd42_write_res * write , bool sync )
5082+ nfsd4_encode_write_response4 (struct xdr_stream * xdr ,
5083+ const struct nfsd4_copy * copy )
50845084{
5085- __be32 * p ;
5086- p = xdr_reserve_space (resp -> xdr , 4 );
5087- if (!p )
5088- return nfserr_resource ;
5085+ const struct nfsd42_write_res * write = & copy -> cp_res ;
5086+ u32 count = nfsd4_copy_is_sync (copy ) ? 0 : 1 ;
5087+ __be32 status ;
50895088
5090- if (sync )
5091- * p ++ = cpu_to_be32 (0 );
5092- else {
5093- __be32 nfserr ;
5094- * p ++ = cpu_to_be32 (1 );
5095- nfserr = nfsd4_encode_stateid4 (resp -> xdr , & write -> cb_stateid );
5096- if (nfserr )
5097- return nfserr ;
5089+ /* wr_callback_id<1> */
5090+ if (xdr_stream_encode_u32 (xdr , count ) != XDR_UNIT )
5091+ return nfserr_resource ;
5092+ if (count ) {
5093+ status = nfsd4_encode_stateid4 (xdr , & write -> cb_stateid );
5094+ if (status != nfs_ok )
5095+ return status ;
50985096 }
5099- p = xdr_reserve_space (resp -> xdr , 8 + 4 + NFS4_VERIFIER_SIZE );
5100- if (!p )
5097+
5098+ /* wr_count */
5099+ status = nfsd4_encode_length4 (xdr , write -> wr_bytes_written );
5100+ if (status != nfs_ok )
5101+ return status ;
5102+ /* wr_committed */
5103+ if (xdr_stream_encode_u32 (xdr , write -> wr_stable_how ) != XDR_UNIT )
51015104 return nfserr_resource ;
5105+ /* wr_writeverf */
5106+ return nfsd4_encode_verifier4 (xdr , & write -> wr_verifier );
5107+ }
51025108
5103- p = xdr_encode_hyper (p , write -> wr_bytes_written );
5104- * p ++ = cpu_to_be32 (write -> wr_stable_how );
5105- p = xdr_encode_opaque_fixed (p , write -> wr_verifier .data ,
5106- NFS4_VERIFIER_SIZE );
5107- return nfs_ok ;
5109+ static __be32 nfsd4_encode_copy_requirements4 (struct xdr_stream * xdr ,
5110+ const struct nfsd4_copy * copy )
5111+ {
5112+ __be32 status ;
5113+
5114+ /* cr_consecutive */
5115+ status = nfsd4_encode_bool (xdr , true);
5116+ if (status != nfs_ok )
5117+ return status ;
5118+ /* cr_synchronous */
5119+ return nfsd4_encode_bool (xdr , nfsd4_copy_is_sync (copy ));
5120+ }
5121+
5122+ static __be32
5123+ nfsd4_encode_copy (struct nfsd4_compoundres * resp , __be32 nfserr ,
5124+ union nfsd4_op_u * u )
5125+ {
5126+ struct nfsd4_copy * copy = & u -> copy ;
5127+
5128+ nfserr = nfsd4_encode_write_response4 (resp -> xdr , copy );
5129+ if (nfserr != nfs_ok )
5130+ return nfserr ;
5131+ return nfsd4_encode_copy_requirements4 (resp -> xdr , copy );
51085132}
51095133
51105134static __be32
@@ -5147,24 +5171,6 @@ nfsd42_encode_nl4_server(struct nfsd4_compoundres *resp, struct nl4_server *ns)
51475171 return 0 ;
51485172}
51495173
5150- static __be32
5151- nfsd4_encode_copy (struct nfsd4_compoundres * resp , __be32 nfserr ,
5152- union nfsd4_op_u * u )
5153- {
5154- struct nfsd4_copy * copy = & u -> copy ;
5155- __be32 * p ;
5156-
5157- nfserr = nfsd42_encode_write_res (resp , & copy -> cp_res ,
5158- nfsd4_copy_is_sync (copy ));
5159- if (nfserr )
5160- return nfserr ;
5161-
5162- p = xdr_reserve_space (resp -> xdr , 4 + 4 );
5163- * p ++ = xdr_one ; /* cr_consecutive */
5164- * p = nfsd4_copy_is_sync (copy ) ? xdr_one : xdr_zero ;
5165- return 0 ;
5166- }
5167-
51685174static __be32
51695175nfsd4_encode_offload_status (struct nfsd4_compoundres * resp , __be32 nfserr ,
51705176 union nfsd4_op_u * u )
0 commit comments