All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Chuck Lever <chuck.lever@oracle.com>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH v3 06/15] xprtrdma: Clean up rpcrdma_ia_open()
Date: Sun, 26 Jul 2015 09:53:37 -0700	[thread overview]
Message-ID: <20150726165337.GC9273@infradead.org> (raw)
In-Reply-To: <20150720190320.10997.40165.stgit@manet.1015granger.net>

Jason has patches that provide a local_dma_lkey in the PD that is always
available.  Do you need this clean up for the next merge window?  If not
it might be worth to postponed it to avoid merge conflicts, specially
as I assume the NFS changes will go in through Trond.

On Mon, Jul 20, 2015 at 03:03:20PM -0400, Chuck Lever wrote:
> Untangle the end of rpcrdma_ia_open() by moving DMA MR set-up, which
> is different for each registration method, to the .ro_open functions.
> 
> This is refactoring only. No behavior change is expected.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> Tested-by: Devesh Sharma <devesh.sharma@avagotech.com>
> ---
>  net/sunrpc/xprtrdma/fmr_ops.c      |   19 +++++++++++
>  net/sunrpc/xprtrdma/frwr_ops.c     |    5 +++
>  net/sunrpc/xprtrdma/physical_ops.c |   25 ++++++++++++++-
>  net/sunrpc/xprtrdma/verbs.c        |   60 +++++++++++-------------------------
>  net/sunrpc/xprtrdma/xprt_rdma.h    |    3 +-
>  5 files changed, 67 insertions(+), 45 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
> index f1e8daf..cb25c89 100644
> --- a/net/sunrpc/xprtrdma/fmr_ops.c
> +++ b/net/sunrpc/xprtrdma/fmr_ops.c
> @@ -39,6 +39,25 @@ static int
>  fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  	    struct rpcrdma_create_data_internal *cdata)
>  {
> +	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	struct ib_mr *mr;
> +
> +	/* Obtain an lkey to use for the regbufs, which are
> +	 * protected from remote access.
> +	 */
> +	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
> +		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +	} else {
> +		mr = ib_get_dma_mr(ia->ri_pd, IB_ACCESS_LOCAL_WRITE);
> +		if (IS_ERR(mr)) {
> +			pr_err("%s: ib_get_dma_mr for failed with %lX\n",
> +			       __func__, PTR_ERR(mr));
> +			return -ENOMEM;
> +		}
> +		ia->ri_dma_lkey = ia->ri_dma_mr->lkey;
> +		ia->ri_dma_mr = mr;
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
> index 04ea914..63f282e 100644
> --- a/net/sunrpc/xprtrdma/frwr_ops.c
> +++ b/net/sunrpc/xprtrdma/frwr_ops.c
> @@ -189,6 +189,11 @@ frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  	struct ib_device_attr *devattr = &ia->ri_devattr;
>  	int depth, delta;
>  
> +	/* Obtain an lkey to use for the regbufs, which are
> +	 * protected from remote access.
> +	 */
> +	ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +
>  	ia->ri_max_frmr_depth =
>  			min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
>  			      devattr->max_fast_reg_page_list_len);
> diff --git a/net/sunrpc/xprtrdma/physical_ops.c b/net/sunrpc/xprtrdma/physical_ops.c
> index 41985d0..72cf8b1 100644
> --- a/net/sunrpc/xprtrdma/physical_ops.c
> +++ b/net/sunrpc/xprtrdma/physical_ops.c
> @@ -23,6 +23,29 @@ static int
>  physical_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  		 struct rpcrdma_create_data_internal *cdata)
>  {
> +	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	struct ib_mr *mr;
> +
> +	/* Obtain an rkey to use for RPC data payloads.
> +	 */
> +	mr = ib_get_dma_mr(ia->ri_pd,
> +			   IB_ACCESS_LOCAL_WRITE |
> +			   IB_ACCESS_REMOTE_WRITE |
> +			   IB_ACCESS_REMOTE_READ);
> +	if (IS_ERR(mr)) {
> +		pr_err("%s: ib_get_dma_mr for failed with %lX\n",
> +		       __func__, PTR_ERR(mr));
> +		return -ENOMEM;
> +	}
> +	ia->ri_dma_mr = mr;
> +
> +	/* Obtain an lkey to use for regbufs.
> +	 */
> +	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)
> +		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +	else
> +		ia->ri_dma_lkey = ia->ri_dma_mr->lkey;
> +
>  	return 0;
>  }
>  
> @@ -51,7 +74,7 @@ physical_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>  	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
>  
>  	rpcrdma_map_one(ia->ri_device, seg, rpcrdma_data_dir(writing));
> -	seg->mr_rkey = ia->ri_bind_mem->rkey;
> +	seg->mr_rkey = ia->ri_dma_mr->rkey;
>  	seg->mr_base = seg->mr_dma;
>  	seg->mr_nsegs = 1;
>  	return 1;
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index da184f9..8516d98 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -493,9 +493,11 @@ rpcrdma_clean_cq(struct ib_cq *cq)
>  int
>  rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  {
> -	int rc, mem_priv;
>  	struct rpcrdma_ia *ia = &xprt->rx_ia;
>  	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	int rc;
> +
> +	ia->ri_dma_mr = NULL;
>  
>  	ia->ri_id = rpcrdma_create_id(xprt, ia, addr);
>  	if (IS_ERR(ia->ri_id)) {
> @@ -519,11 +521,6 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  		goto out3;
>  	}
>  
> -	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
> -		ia->ri_have_dma_lkey = 1;
> -		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> -	}
> -
>  	if (memreg == RPCRDMA_FRMR) {
>  		/* Requires both frmr reg and local dma lkey */
>  		if (((devattr->device_cap_flags &
> @@ -543,38 +540,15 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  		}
>  	}
>  
> -	/*
> -	 * Optionally obtain an underlying physical identity mapping in
> -	 * order to do a memory window-based bind. This base registration
> -	 * is protected from remote access - that is enabled only by binding
> -	 * for the specific bytes targeted during each RPC operation, and
> -	 * revoked after the corresponding completion similar to a storage
> -	 * adapter.
> -	 */
>  	switch (memreg) {
>  	case RPCRDMA_FRMR:
>  		ia->ri_ops = &rpcrdma_frwr_memreg_ops;
>  		break;
>  	case RPCRDMA_ALLPHYSICAL:
>  		ia->ri_ops = &rpcrdma_physical_memreg_ops;
> -		mem_priv = IB_ACCESS_LOCAL_WRITE |
> -				IB_ACCESS_REMOTE_WRITE |
> -				IB_ACCESS_REMOTE_READ;
> -		goto register_setup;
> +		break;
>  	case RPCRDMA_MTHCAFMR:
>  		ia->ri_ops = &rpcrdma_fmr_memreg_ops;
> -		if (ia->ri_have_dma_lkey)
> -			break;
> -		mem_priv = IB_ACCESS_LOCAL_WRITE;
> -	register_setup:
> -		ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv);
> -		if (IS_ERR(ia->ri_bind_mem)) {
> -			printk(KERN_ALERT "%s: ib_get_dma_mr for "
> -				"phys register failed with %lX\n",
> -				__func__, PTR_ERR(ia->ri_bind_mem));
> -			rc = -ENOMEM;
> -			goto out3;
> -		}
>  		break;
>  	default:
>  		printk(KERN_ERR "RPC: Unsupported memory "
> @@ -606,15 +580,7 @@ out1:
>  void
>  rpcrdma_ia_close(struct rpcrdma_ia *ia)
>  {
> -	int rc;
> -
>  	dprintk("RPC:       %s: entering\n", __func__);
> -	if (ia->ri_bind_mem != NULL) {
> -		rc = ib_dereg_mr(ia->ri_bind_mem);
> -		dprintk("RPC:       %s: ib_dereg_mr returned %i\n",
> -			__func__, rc);
> -	}
> -
>  	if (ia->ri_id != NULL && !IS_ERR(ia->ri_id)) {
>  		if (ia->ri_id->qp)
>  			rdma_destroy_qp(ia->ri_id);
> @@ -661,8 +627,10 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
>  	if (cdata->padding) {
>  		ep->rep_padbuf = rpcrdma_alloc_regbuf(ia, cdata->padding,
>  						      GFP_KERNEL);
> -		if (IS_ERR(ep->rep_padbuf))
> -			return PTR_ERR(ep->rep_padbuf);
> +		if (IS_ERR(ep->rep_padbuf)) {
> +			rc = PTR_ERR(ep->rep_padbuf);
> +			goto out0;
> +		}
>  	} else
>  		ep->rep_padbuf = NULL;
>  
> @@ -749,6 +717,9 @@ out2:
>  			__func__, err);
>  out1:
>  	rpcrdma_free_regbuf(ia, ep->rep_padbuf);
> +out0:
> +	if (ia->ri_dma_mr)
> +		ib_dereg_mr(ia->ri_dma_mr);
>  	return rc;
>  }
>  
> @@ -788,6 +759,12 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
>  	if (rc)
>  		dprintk("RPC:       %s: ib_destroy_cq returned %i\n",
>  			__func__, rc);
> +
> +	if (ia->ri_dma_mr) {
> +		rc = ib_dereg_mr(ia->ri_dma_mr);
> +		dprintk("RPC:       %s: ib_dereg_mr returned %i\n",
> +			__func__, rc);
> +	}
>  }
>  
>  /*
> @@ -1262,8 +1239,7 @@ rpcrdma_alloc_regbuf(struct rpcrdma_ia *ia, size_t size, gfp_t flags)
>  		goto out_free;
>  
>  	iov->length = size;
> -	iov->lkey = ia->ri_have_dma_lkey ?
> -				ia->ri_dma_lkey : ia->ri_bind_mem->lkey;
> +	iov->lkey = ia->ri_dma_lkey;
>  	rb->rg_size = size;
>  	rb->rg_owner = NULL;
>  	return rb;
> diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
> index ce4e79e..8219011 100644
> --- a/net/sunrpc/xprtrdma/xprt_rdma.h
> +++ b/net/sunrpc/xprtrdma/xprt_rdma.h
> @@ -65,9 +65,8 @@ struct rpcrdma_ia {
>  	struct ib_device	*ri_device;
>  	struct rdma_cm_id 	*ri_id;
>  	struct ib_pd		*ri_pd;
> -	struct ib_mr		*ri_bind_mem;
> +	struct ib_mr		*ri_dma_mr;
>  	u32			ri_dma_lkey;
> -	int			ri_have_dma_lkey;
>  	struct completion	ri_done;
>  	int			ri_async_rc;
>  	unsigned int		ri_max_frmr_depth;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 06/15] xprtrdma: Clean up rpcrdma_ia_open()
Date: Sun, 26 Jul 2015 09:53:37 -0700	[thread overview]
Message-ID: <20150726165337.GC9273@infradead.org> (raw)
In-Reply-To: <20150720190320.10997.40165.stgit-FYjufvaPoItvLzlybtyyYzGyq/o6K9yX@public.gmane.org>

Jason has patches that provide a local_dma_lkey in the PD that is always
available.  Do you need this clean up for the next merge window?  If not
it might be worth to postponed it to avoid merge conflicts, specially
as I assume the NFS changes will go in through Trond.

On Mon, Jul 20, 2015 at 03:03:20PM -0400, Chuck Lever wrote:
> Untangle the end of rpcrdma_ia_open() by moving DMA MR set-up, which
> is different for each registration method, to the .ro_open functions.
> 
> This is refactoring only. No behavior change is expected.
> 
> Signed-off-by: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Tested-by: Devesh Sharma <devesh.sharma-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org>
> ---
>  net/sunrpc/xprtrdma/fmr_ops.c      |   19 +++++++++++
>  net/sunrpc/xprtrdma/frwr_ops.c     |    5 +++
>  net/sunrpc/xprtrdma/physical_ops.c |   25 ++++++++++++++-
>  net/sunrpc/xprtrdma/verbs.c        |   60 +++++++++++-------------------------
>  net/sunrpc/xprtrdma/xprt_rdma.h    |    3 +-
>  5 files changed, 67 insertions(+), 45 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
> index f1e8daf..cb25c89 100644
> --- a/net/sunrpc/xprtrdma/fmr_ops.c
> +++ b/net/sunrpc/xprtrdma/fmr_ops.c
> @@ -39,6 +39,25 @@ static int
>  fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  	    struct rpcrdma_create_data_internal *cdata)
>  {
> +	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	struct ib_mr *mr;
> +
> +	/* Obtain an lkey to use for the regbufs, which are
> +	 * protected from remote access.
> +	 */
> +	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
> +		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +	} else {
> +		mr = ib_get_dma_mr(ia->ri_pd, IB_ACCESS_LOCAL_WRITE);
> +		if (IS_ERR(mr)) {
> +			pr_err("%s: ib_get_dma_mr for failed with %lX\n",
> +			       __func__, PTR_ERR(mr));
> +			return -ENOMEM;
> +		}
> +		ia->ri_dma_lkey = ia->ri_dma_mr->lkey;
> +		ia->ri_dma_mr = mr;
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
> index 04ea914..63f282e 100644
> --- a/net/sunrpc/xprtrdma/frwr_ops.c
> +++ b/net/sunrpc/xprtrdma/frwr_ops.c
> @@ -189,6 +189,11 @@ frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  	struct ib_device_attr *devattr = &ia->ri_devattr;
>  	int depth, delta;
>  
> +	/* Obtain an lkey to use for the regbufs, which are
> +	 * protected from remote access.
> +	 */
> +	ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +
>  	ia->ri_max_frmr_depth =
>  			min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
>  			      devattr->max_fast_reg_page_list_len);
> diff --git a/net/sunrpc/xprtrdma/physical_ops.c b/net/sunrpc/xprtrdma/physical_ops.c
> index 41985d0..72cf8b1 100644
> --- a/net/sunrpc/xprtrdma/physical_ops.c
> +++ b/net/sunrpc/xprtrdma/physical_ops.c
> @@ -23,6 +23,29 @@ static int
>  physical_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
>  		 struct rpcrdma_create_data_internal *cdata)
>  {
> +	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	struct ib_mr *mr;
> +
> +	/* Obtain an rkey to use for RPC data payloads.
> +	 */
> +	mr = ib_get_dma_mr(ia->ri_pd,
> +			   IB_ACCESS_LOCAL_WRITE |
> +			   IB_ACCESS_REMOTE_WRITE |
> +			   IB_ACCESS_REMOTE_READ);
> +	if (IS_ERR(mr)) {
> +		pr_err("%s: ib_get_dma_mr for failed with %lX\n",
> +		       __func__, PTR_ERR(mr));
> +		return -ENOMEM;
> +	}
> +	ia->ri_dma_mr = mr;
> +
> +	/* Obtain an lkey to use for regbufs.
> +	 */
> +	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)
> +		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> +	else
> +		ia->ri_dma_lkey = ia->ri_dma_mr->lkey;
> +
>  	return 0;
>  }
>  
> @@ -51,7 +74,7 @@ physical_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
>  	struct rpcrdma_ia *ia = &r_xprt->rx_ia;
>  
>  	rpcrdma_map_one(ia->ri_device, seg, rpcrdma_data_dir(writing));
> -	seg->mr_rkey = ia->ri_bind_mem->rkey;
> +	seg->mr_rkey = ia->ri_dma_mr->rkey;
>  	seg->mr_base = seg->mr_dma;
>  	seg->mr_nsegs = 1;
>  	return 1;
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index da184f9..8516d98 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -493,9 +493,11 @@ rpcrdma_clean_cq(struct ib_cq *cq)
>  int
>  rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  {
> -	int rc, mem_priv;
>  	struct rpcrdma_ia *ia = &xprt->rx_ia;
>  	struct ib_device_attr *devattr = &ia->ri_devattr;
> +	int rc;
> +
> +	ia->ri_dma_mr = NULL;
>  
>  	ia->ri_id = rpcrdma_create_id(xprt, ia, addr);
>  	if (IS_ERR(ia->ri_id)) {
> @@ -519,11 +521,6 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  		goto out3;
>  	}
>  
> -	if (devattr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
> -		ia->ri_have_dma_lkey = 1;
> -		ia->ri_dma_lkey = ia->ri_device->local_dma_lkey;
> -	}
> -
>  	if (memreg == RPCRDMA_FRMR) {
>  		/* Requires both frmr reg and local dma lkey */
>  		if (((devattr->device_cap_flags &
> @@ -543,38 +540,15 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
>  		}
>  	}
>  
> -	/*
> -	 * Optionally obtain an underlying physical identity mapping in
> -	 * order to do a memory window-based bind. This base registration
> -	 * is protected from remote access - that is enabled only by binding
> -	 * for the specific bytes targeted during each RPC operation, and
> -	 * revoked after the corresponding completion similar to a storage
> -	 * adapter.
> -	 */
>  	switch (memreg) {
>  	case RPCRDMA_FRMR:
>  		ia->ri_ops = &rpcrdma_frwr_memreg_ops;
>  		break;
>  	case RPCRDMA_ALLPHYSICAL:
>  		ia->ri_ops = &rpcrdma_physical_memreg_ops;
> -		mem_priv = IB_ACCESS_LOCAL_WRITE |
> -				IB_ACCESS_REMOTE_WRITE |
> -				IB_ACCESS_REMOTE_READ;
> -		goto register_setup;
> +		break;
>  	case RPCRDMA_MTHCAFMR:
>  		ia->ri_ops = &rpcrdma_fmr_memreg_ops;
> -		if (ia->ri_have_dma_lkey)
> -			break;
> -		mem_priv = IB_ACCESS_LOCAL_WRITE;
> -	register_setup:
> -		ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv);
> -		if (IS_ERR(ia->ri_bind_mem)) {
> -			printk(KERN_ALERT "%s: ib_get_dma_mr for "
> -				"phys register failed with %lX\n",
> -				__func__, PTR_ERR(ia->ri_bind_mem));
> -			rc = -ENOMEM;
> -			goto out3;
> -		}
>  		break;
>  	default:
>  		printk(KERN_ERR "RPC: Unsupported memory "
> @@ -606,15 +580,7 @@ out1:
>  void
>  rpcrdma_ia_close(struct rpcrdma_ia *ia)
>  {
> -	int rc;
> -
>  	dprintk("RPC:       %s: entering\n", __func__);
> -	if (ia->ri_bind_mem != NULL) {
> -		rc = ib_dereg_mr(ia->ri_bind_mem);
> -		dprintk("RPC:       %s: ib_dereg_mr returned %i\n",
> -			__func__, rc);
> -	}
> -
>  	if (ia->ri_id != NULL && !IS_ERR(ia->ri_id)) {
>  		if (ia->ri_id->qp)
>  			rdma_destroy_qp(ia->ri_id);
> @@ -661,8 +627,10 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
>  	if (cdata->padding) {
>  		ep->rep_padbuf = rpcrdma_alloc_regbuf(ia, cdata->padding,
>  						      GFP_KERNEL);
> -		if (IS_ERR(ep->rep_padbuf))
> -			return PTR_ERR(ep->rep_padbuf);
> +		if (IS_ERR(ep->rep_padbuf)) {
> +			rc = PTR_ERR(ep->rep_padbuf);
> +			goto out0;
> +		}
>  	} else
>  		ep->rep_padbuf = NULL;
>  
> @@ -749,6 +717,9 @@ out2:
>  			__func__, err);
>  out1:
>  	rpcrdma_free_regbuf(ia, ep->rep_padbuf);
> +out0:
> +	if (ia->ri_dma_mr)
> +		ib_dereg_mr(ia->ri_dma_mr);
>  	return rc;
>  }
>  
> @@ -788,6 +759,12 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
>  	if (rc)
>  		dprintk("RPC:       %s: ib_destroy_cq returned %i\n",
>  			__func__, rc);
> +
> +	if (ia->ri_dma_mr) {
> +		rc = ib_dereg_mr(ia->ri_dma_mr);
> +		dprintk("RPC:       %s: ib_dereg_mr returned %i\n",
> +			__func__, rc);
> +	}
>  }
>  
>  /*
> @@ -1262,8 +1239,7 @@ rpcrdma_alloc_regbuf(struct rpcrdma_ia *ia, size_t size, gfp_t flags)
>  		goto out_free;
>  
>  	iov->length = size;
> -	iov->lkey = ia->ri_have_dma_lkey ?
> -				ia->ri_dma_lkey : ia->ri_bind_mem->lkey;
> +	iov->lkey = ia->ri_dma_lkey;
>  	rb->rg_size = size;
>  	rb->rg_owner = NULL;
>  	return rb;
> diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
> index ce4e79e..8219011 100644
> --- a/net/sunrpc/xprtrdma/xprt_rdma.h
> +++ b/net/sunrpc/xprtrdma/xprt_rdma.h
> @@ -65,9 +65,8 @@ struct rpcrdma_ia {
>  	struct ib_device	*ri_device;
>  	struct rdma_cm_id 	*ri_id;
>  	struct ib_pd		*ri_pd;
> -	struct ib_mr		*ri_bind_mem;
> +	struct ib_mr		*ri_dma_mr;
>  	u32			ri_dma_lkey;
> -	int			ri_have_dma_lkey;
>  	struct completion	ri_done;
>  	int			ri_async_rc;
>  	unsigned int		ri_max_frmr_depth;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-07-26 16:53 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 19:02 [PATCH v3 00/15] NFS/RDMA client side for Linux 4.3 Chuck Lever
2015-07-20 19:02 ` Chuck Lever
2015-07-20 19:02 ` [PATCH v3 01/15] xprtrdma: Make xprt_setup_rdma() agnostic to family of server address Chuck Lever
2015-07-20 19:02   ` Chuck Lever
2015-07-26 16:49   ` Christoph Hellwig
2015-07-26 16:49     ` Christoph Hellwig
2015-07-20 19:02 ` [PATCH v3 02/15] xprtrdma: Raise maximum payload size to one megabyte Chuck Lever
2015-07-20 19:02   ` Chuck Lever
2015-07-20 19:02 ` [PATCH v3 03/15] xprtrdma: Increase default credit limit Chuck Lever
2015-07-20 19:02   ` Chuck Lever
2015-07-20 19:03 ` [PATCH v3 04/15] xprtrdma: Don't fall back to PHYSICAL memory registration Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-26 16:50   ` Christoph Hellwig
2015-07-26 16:50     ` Christoph Hellwig
2015-07-20 19:03 ` [PATCH v3 05/15] xprtrdma: Remove last ib_reg_phys_mr() call site Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-20 20:34   ` Tom Talpey
2015-07-20 20:34     ` Tom Talpey
2015-07-20 20:55     ` Chuck Lever
2015-07-20 20:55       ` Chuck Lever
2015-07-20 21:55       ` Tom Talpey
2015-07-20 21:55         ` Tom Talpey
2015-07-20 22:21         ` Chuck Lever
2015-07-20 22:21           ` Chuck Lever
2015-07-20 22:30           ` Tom Talpey
2015-07-20 22:30             ` Tom Talpey
2015-07-20 21:05     ` Jason Gunthorpe
2015-07-20 21:05       ` Jason Gunthorpe
2015-07-20 21:16       ` Steve Wise
2015-07-20 21:16         ` Steve Wise
2015-07-20 22:04         ` Tom Talpey
2015-07-20 22:04           ` Tom Talpey
2015-07-20 22:17           ` Jason Gunthorpe
2015-07-20 22:17             ` Jason Gunthorpe
2015-07-20 22:26             ` Tom Talpey
2015-07-20 22:26               ` Tom Talpey
2015-07-20 22:41           ` Steve Wise
2015-07-20 22:41             ` Steve Wise
2015-07-20 22:42             ` Jason Gunthorpe
2015-07-20 22:42               ` Jason Gunthorpe
2015-07-21 22:41               ` Steve Wise
2015-07-21 22:41                 ` Steve Wise
2015-07-21 22:54                 ` Jason Gunthorpe
2015-07-21 22:54                   ` Jason Gunthorpe
2015-07-22 13:58                   ` Steve Wise
2015-07-22 13:58                     ` Steve Wise
2015-07-21  0:15             ` Tom Talpey
2015-07-21  0:15               ` Tom Talpey
2015-07-21 14:33               ` Steve Wise
2015-07-21 14:33                 ` Steve Wise
2015-07-21 20:47                 ` Tom Talpey
2015-07-21 20:47                   ` Tom Talpey
2015-07-21 20:55                   ` Steve Wise
2015-07-21 20:55                     ` Steve Wise
2015-07-21 21:22                   ` Steve Wise
2015-07-21 21:22                     ` Steve Wise
2015-07-20 21:34       ` Steve Wise
2015-07-20 21:34         ` Steve Wise
2015-07-20 21:37       ` Steve Wise
2015-07-20 21:37         ` Steve Wise
2015-07-20 22:13         ` Jason Gunthorpe
2015-07-20 22:13           ` Jason Gunthorpe
2015-07-20 22:43           ` Steve Wise
2015-07-20 22:43             ` Steve Wise
2015-07-20 22:54             ` Jason Gunthorpe
2015-07-20 22:54               ` Jason Gunthorpe
2015-07-20 22:54               ` Steve Wise
2015-07-20 22:54                 ` Steve Wise
2015-07-20 22:26   ` Jason Gunthorpe
2015-07-20 22:26     ` Jason Gunthorpe
2015-07-20 22:31     ` Chuck Lever
2015-07-20 22:31       ` Chuck Lever
2015-07-20 22:41       ` Jason Gunthorpe
2015-07-20 22:41         ` Jason Gunthorpe
2015-07-20 23:36         ` Chuck Lever
2015-07-20 23:36           ` Chuck Lever
2015-07-21  0:11           ` Tom Talpey
2015-07-21  0:11             ` Tom Talpey
2015-07-21  0:34             ` Chuck Lever
2015-07-21  0:34               ` Chuck Lever
2015-07-21  1:03               ` Tom Talpey
2015-07-21  1:03                 ` Tom Talpey
2015-07-20 19:03 ` [PATCH v3 06/15] xprtrdma: Clean up rpcrdma_ia_open() Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-26 16:53   ` Christoph Hellwig [this message]
2015-07-26 16:53     ` Christoph Hellwig
2015-07-26 18:21     ` Chuck Lever
2015-07-26 18:21       ` Chuck Lever
2015-07-26 18:51       ` Christoph Hellwig
2015-07-26 18:51         ` Christoph Hellwig
2015-07-20 19:03 ` [PATCH v3 07/15] xprtrdma: Remove logic that constructs RDMA_MSGP type calls Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-20 19:03 ` [PATCH v3 08/15] xprtrdma: Account for RPC/RDMA header size when deciding to inline Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-20 19:03 ` [PATCH v3 09/15] xprtrdma: Always provide a write list when sending NFS READ Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-20 19:03 ` [PATCH v3 10/15] xprtrdma: Don't provide a reply chunk when expecting a short reply Chuck Lever
2015-07-20 19:03   ` Chuck Lever
2015-07-20 19:04 ` [PATCH v3 11/15] xprtrdma: Fix XDR tail buffer marshalling Chuck Lever
2015-07-20 19:04   ` Chuck Lever
2015-07-20 19:04 ` [PATCH v3 12/15] xprtrdma: Fix large NFS SYMLINK calls Chuck Lever
2015-07-20 19:04   ` Chuck Lever
2015-07-20 19:04 ` [PATCH v3 13/15] xprtrdma: Clean up xprt_rdma_print_stats() Chuck Lever
2015-07-20 19:04   ` Chuck Lever
2015-07-20 19:04 ` [PATCH v3 14/15] xprtrdma: Count RDMA_NOMSG type calls Chuck Lever
2015-07-20 19:04   ` Chuck Lever
2015-07-20 19:04 ` [PATCH v3 15/15] core: Remove the ib_reg_phys_mr() and ib_rereg_phys_mr() verbs Chuck Lever
2015-07-20 19:04   ` Chuck Lever
2015-07-21 20:08   ` Anna Schumaker
2015-07-21 20:08     ` Anna Schumaker
2015-07-21 20:16     ` Chuck Lever
2015-07-21 20:16       ` Chuck Lever
2015-07-21 20:18       ` Anna Schumaker
2015-07-21 20:18         ` Anna Schumaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150726165337.GC9273@infradead.org \
    --to=hch@infradead.org \
    --cc=chuck.lever@oracle.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.