Messages in this thread Patch in this message | | | From | roderich@nodebonn ... | Subject | [patch] Re: NFS writes | Date | Mon, 26 May 1997 18:18:22 +0200 |
| |
Tim Waugh <tmw20@cam.ac.uk> said: > This patch fixes the problem I was seeing (to do with NFS writes).
Yup, this fixes the NFS writes with 0 bytes data! But I also have problems with NFS writes where the data length is not a multiple of 4 (e.g. the last odd-sized write request when doing a file copy). Problem seems to be that the marshalling code in fs/nfs/nfs2xdr.c does not pad the NFS data up to the next multiple of 4 (as required by the XDR spec). At least some NFS servers don't like this and return a GARBAGE_ARGS RPC error.
The following patch (against 2.1.40) fixes this by adding a third io buffer (containing from 1 to 3 bytes) if padding is necessary. Maybe there's a better way to do this?
Cheers, Roderich
--- nfs2xdr.c.ORIG Mon May 26 16:45:04 1997 +++ nfs2xdr.c Mon May 26 18:59:51 1997 @@ -257,6 +257,8 @@ static int nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) { + int pad; + p = xdr_encode_fhandle(p, args->fh); *p++ = htonl(args->offset); *p++ = htonl(args->offset); @@ -268,6 +270,16 @@ req->rq_svec[1].iov_len = args->count; req->rq_slen += args->count; req->rq_snr = 2; + + pad = (QUADLEN(args->count) << 2) - args->count; + if (pad > 0) + { + req->rq_svec[2].iov_base = (void *)p; + req->rq_svec[2].iov_len = pad; + *p++ = 0; + req->rq_slen += pad; + req->rq_snr = 3; + } return 0; }
| |