• Chuck Lever's avatar
    svcrdma: Tail iovec leaves an orphaned DMA mapping · cd2abef6
    Chuck Lever authored
    commit cace564f upstream.
    
    The ctxt's count field is overloaded to mean the number of pages in
    the ctxt->page array and the number of SGEs in the ctxt->sge array.
    Typically these two numbers are the same.
    
    However, when an inline RPC reply is constructed from an xdr_buf
    with a tail iovec, the head and tail often occupy the same page,
    but each are DMA mapped independently. In that case, ->count equals
    the number of pages, but it does not equal the number of SGEs.
    There's one more SGE, for the tail iovec. Hence there is one more
    DMA mapping than there are pages in the ctxt->page array.
    
    This isn't a real problem until the server's iommu is enabled. Then
    each RPC reply that has content in that iovec orphans a DMA mapping
    that consists of real resources.
    
    krb5i and krb5p always populate that tail iovec. After a couple
    million sent krb5i/p RPC replies, the NFS server starts behaving
    erratically. Reboot is needed to clear the problem.
    
    Fixes: 9d11b51c ("svcrdma: Fix send_reply() scatter/gather set-up")
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
    [bwh: Backported to 3.16:
     - Adjust context
     - Drop changes to svc_rdma_bc_sendto()
     - s/xprt->sc_pd->local_dma_lkey/xprt->sc_dma_lkey/
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    cd2abef6
svc_rdma_recvfrom.c 17.3 KB