u32 xdr_off;
        int chunk_off;
        int chunk_no;
+       int nchunks;
        struct rpcrdma_write_array *arg_ary;
        struct rpcrdma_write_array *res_ary;
        int ret;
                &rdma_resp->rm_body.rm_chunks[1];
 
        /* Write chunks start at the pagelist */
+       nchunks = be32_to_cpu(arg_ary->wc_nchunks);
        for (xdr_off = rqstp->rq_res.head[0].iov_len, chunk_no = 0;
-            xfer_len && chunk_no < arg_ary->wc_nchunks;
+            xfer_len && chunk_no < nchunks;
             chunk_no++) {
                struct rpcrdma_segment *arg_ch;
                u64 rs_offset;
 
                arg_ch = &arg_ary->wc_array[chunk_no].wc_target;
-               write_len = min(xfer_len, ntohl(arg_ch->rs_length));
+               write_len = min(xfer_len, be32_to_cpu(arg_ch->rs_length));
 
                /* Prepare the response chunk given the length actually
                 * written */
                chunk_off = 0;
                while (write_len) {
                        ret = send_write(xprt, rqstp,
-                                        ntohl(arg_ch->rs_handle),
+                                        be32_to_cpu(arg_ch->rs_handle),
                                         rs_offset + chunk_off,
                                         xdr_off,
                                         write_len,
                &rdma_resp->rm_body.rm_chunks[2];
 
        /* xdr offset starts at RPC message */
-       nchunks = ntohl(arg_ary->wc_nchunks);
+       nchunks = be32_to_cpu(arg_ary->wc_nchunks);
        for (xdr_off = 0, chunk_no = 0;
             xfer_len && chunk_no < nchunks;
             chunk_no++) {
                u64 rs_offset;
                ch = &arg_ary->wc_array[chunk_no].wc_target;
-               write_len = min(xfer_len, htonl(ch->rs_length));
+               write_len = min(xfer_len, be32_to_cpu(ch->rs_length));
 
                /* Prepare the reply chunk given the length actually
                 * written */
                chunk_off = 0;
                while (write_len) {
                        ret = send_write(xprt, rqstp,
-                                        ntohl(ch->rs_handle),
+                                        be32_to_cpu(ch->rs_handle),
                                         rs_offset + chunk_off,
                                         xdr_off,
                                         write_len,