Re: [PATCH v2 1/1] librdmacm: Return errno on create_qp failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 29, 2018 at 03:20:45PM +0300, Yuval Shaia wrote:
> Upon QP creation failure provider's create_qp function sets errno with
> error code and return NULL to caller.
> 
> Let's return this errno to caller to reflect the exact reason for the
> error.
> 
> Signed-off-by: Yuval Shaia <yuval.shaia@xxxxxxxxxx>
>  librdmacm/cma.c | 4 +++-
>  librdmacm/cma.h | 8 ++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/librdmacm/cma.c b/librdmacm/cma.c
> index fa370650..9920eaba 100644
> +++ b/librdmacm/cma.c
> @@ -1367,9 +1367,11 @@ int rdma_create_qp_ex(struct rdma_cm_id *id,
>  		attr->recv_cq = id->recv_cq;
>  	if (id->srq && !attr->srq)
>  		attr->srq = id->srq;
> +
> +	errno = 0;
>  	qp = ibv_create_qp_ex(id->verbs, attr);
>  	if (!qp) {
> -		ret = ERR(ENOMEM);
> +		ret = CHK_ERRNO("ibv_create_qp_ex");
>  		goto err1;
>  	}
>  
> diff --git a/librdmacm/cma.h b/librdmacm/cma.h
> index 62821055..c2dc4865 100644
> +++ b/librdmacm/cma.h
> @@ -41,6 +41,7 @@
>  #include <endian.h>
>  #include <semaphore.h>
>  #include <stdatomic.h>
> +#include <stdio.h>
>  
>  #include <rdma/rdma_cma.h>
>  #include <infiniband/ib.h>
> @@ -92,6 +93,13 @@ static inline int ERR(int err)
>  	return -1;
>  }
>  
> +static inline int CHK_ERRNO(const char *funcname)
> +{
> +	if (!errno)
> +		fprintf(stderr, "Function %s did not set errno\n", funcname);
> +	return -1;
> +}

This doesn't belong in cma, this is a verbs problem. ibv_create_qp_ex
is supposed to return errno, cma should assume it does.

If we have broken drivers then they need to be fixed, or we need core
verbs to wrapper the driver callback with one that fixes it.

Also, no prints in libraries. Just return EINVAL.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux