{
        unsigned int i, total_len;
        struct rpcrdma_write_chunk *cur_wchunk;
+       char *base = (char *)rdmab_to_msg(rep->rr_rdmabuf);
 
        i = be32_to_cpu(**iptrp);
        if (i > max)
                        return -1;
                cur_wchunk = (struct rpcrdma_write_chunk *) w;
        }
-       if ((char *) cur_wchunk > rep->rr_base + rep->rr_len)
+       if ((char *)cur_wchunk > base + rep->rr_len)
                return -1;
 
        *iptrp = (__be32 *) cur_wchunk;
                dprintk("RPC:       %s: short/invalid reply\n", __func__);
                goto repost;
        }
-       headerp = (struct rpcrdma_msg *) rep->rr_base;
+       headerp = rdmab_to_msg(rep->rr_rdmabuf);
        if (headerp->rm_vers != rpcrdma_version) {
                dprintk("RPC:       %s: invalid version %d\n",
                        __func__, be32_to_cpu(headerp->rm_vers));
 
 
        rep->rr_len = wc->byte_len;
        ib_dma_sync_single_for_cpu(rdmab_to_ia(rep->rr_buffer)->ri_id->device,
-                       rep->rr_iov.addr, rep->rr_len, DMA_FROM_DEVICE);
-       prefetch(rep->rr_base);
+                                  rdmab_addr(rep->rr_rdmabuf),
+                                  rep->rr_len, DMA_FROM_DEVICE);
+       prefetch(rdmab_to_msg(rep->rr_rdmabuf));
 
 out_schedule:
        list_add_tail(&rep->rr_list, sched_list);
 rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt)
 {
        struct rpcrdma_create_data_internal *cdata = &r_xprt->rx_data;
-       size_t rlen = 1 << fls(cdata->inline_rsize +
-                              sizeof(struct rpcrdma_rep));
        struct rpcrdma_ia *ia = &r_xprt->rx_ia;
        struct rpcrdma_rep *rep;
        int rc;
 
        rc = -ENOMEM;
-       rep = kmalloc(rlen, GFP_KERNEL);
+       rep = kzalloc(sizeof(*rep), GFP_KERNEL);
        if (rep == NULL)
                goto out;
-       memset(rep, 0, sizeof(*rep));
 
-       rc = rpcrdma_register_internal(ia, rep->rr_base, rlen -
-                                      offsetof(struct rpcrdma_rep, rr_base),
-                                      &rep->rr_handle, &rep->rr_iov);
-       if (rc)
+       rep->rr_rdmabuf = rpcrdma_alloc_regbuf(ia, cdata->inline_rsize,
+                                              GFP_KERNEL);
+       if (IS_ERR(rep->rr_rdmabuf)) {
+               rc = PTR_ERR(rep->rr_rdmabuf);
                goto out_free;
+       }
 
        rep->rr_buffer = &r_xprt->rx_buf;
        return rep;
        if (!rep)
                return;
 
-       rpcrdma_deregister_internal(ia, rep->rr_handle, &rep->rr_iov);
+       rpcrdma_free_regbuf(ia, rep->rr_rdmabuf);
        kfree(rep);
 }
 
 
        recv_wr.next = NULL;
        recv_wr.wr_id = (u64) (unsigned long) rep;
-       recv_wr.sg_list = &rep->rr_iov;
+       recv_wr.sg_list = &rep->rr_rdmabuf->rg_iov;
        recv_wr.num_sge = 1;
 
        ib_dma_sync_single_for_cpu(ia->ri_id->device,
-               rep->rr_iov.addr, rep->rr_iov.length, DMA_BIDIRECTIONAL);
+                                  rdmab_addr(rep->rr_rdmabuf),
+                                  rdmab_length(rep->rr_rdmabuf),
+                                  DMA_BIDIRECTIONAL);
 
        rc = ib_post_recv(ia->ri_id->qp, &recv_wr, &recv_wr_fail);
 
 
 struct rpcrdma_buffer;
 
 struct rpcrdma_rep {
-       unsigned int    rr_len;         /* actual received reply length */
-       struct rpcrdma_buffer *rr_buffer; /* home base for this structure */
-       struct rpc_xprt *rr_xprt;       /* needed for request/reply matching */
-       void (*rr_func)(struct rpcrdma_rep *);/* called by tasklet in softint */
-       struct list_head rr_list;       /* tasklet list */
-       struct ib_sge   rr_iov;         /* for posting */
-       struct ib_mr    *rr_handle;     /* handle for mem in rr_iov */
-       char    rr_base[MAX_RPCRDMAHDR]; /* minimal inline receive buffer */
+       unsigned int            rr_len;
+       struct rpcrdma_buffer   *rr_buffer;
+       struct rpc_xprt         *rr_xprt;
+       void                    (*rr_func)(struct rpcrdma_rep *);
+       struct list_head        rr_list;
+       struct rpcrdma_regbuf   *rr_rdmabuf;
 };
 
 /*