From patchwork Thu Aug 2 16:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10553941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59C839093 for ; Thu, 2 Aug 2018 16:14:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A19C2C2CA for ; Thu, 2 Aug 2018 16:14:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E2792C2F7; Thu, 2 Aug 2018 16:14:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9C4D2C2CA for ; Thu, 2 Aug 2018 16:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbeHBSG0 (ORCPT ); Thu, 2 Aug 2018 14:06:26 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48788 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726547AbeHBSG0 (ORCPT ); Thu, 2 Aug 2018 14:06:26 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Aug 2018 19:17:59 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w72GEYGx029959; Thu, 2 Aug 2018 19:14:34 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w72GEYTI019400; Thu, 2 Aug 2018 19:14:34 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w72GEYuG019399; Thu, 2 Aug 2018 19:14:34 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 4/6] verbs: Consider EIO upon write destroy commands Date: Thu, 2 Aug 2018 19:13:34 +0300 Message-Id: <1533226416-19122-5-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1533226416-19122-1-git-send-email-yishaih@mellanox.com> References: <1533226416-19122-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use verbs_is_destroy_err() upon write destroy commands to consider the EIO use case. Signed-off-by: Yishai Hadas --- libibverbs/cmd.c | 62 +++++++++++++++++++++++++++++++++++++++++++---------- libibverbs/cmd_cq.c | 2 +- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 89f8778..d88b3aa 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -338,11 +338,16 @@ int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd, int ibv_cmd_dealloc_pd(struct ibv_pd *pd) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_DEALLOC_PD); + int ret; *req = (struct ib_uverbs_dealloc_pd) { .pd_handle = pd->handle, }; - return execute_write(pd->context, req, NULL); + ret = execute_write(pd->context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd, @@ -380,11 +385,16 @@ int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd, int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_CLOSE_XRCD); + int ret; *req = (struct ib_uverbs_close_xrcd){ .xrcd_handle = xrcd->handle, }; - return execute_write(xrcd->xrcd.context, req, NULL); + ret = execute_write(xrcd->xrcd.context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, @@ -448,11 +458,16 @@ int ibv_cmd_rereg_mr(struct verbs_mr *vmr, uint32_t flags, void *addr, int ibv_cmd_dereg_mr(struct verbs_mr *vmr) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_DEREG_MR); + int ret; *req = (struct ib_uverbs_dereg_mr){ .mr_handle = vmr->ibv_mr.handle, }; - return execute_write(vmr->ibv_mr.context, req, NULL); + ret = execute_write(vmr->ibv_mr.context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type, @@ -482,11 +497,16 @@ int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type, int ibv_cmd_dealloc_mw(struct ibv_mw *mw) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_DEALLOC_MW); + int ret; *req = (struct ib_uverbs_dealloc_mw) { .mw_handle = mw->handle, }; - return execute_write(mw->context, req, NULL); + ret = execute_write(mw->context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc) @@ -767,7 +787,7 @@ int ibv_cmd_destroy_srq(struct ibv_srq *srq) }; ret = execute_write(srq->context, req, &resp); - if (ret) + if (verbs_is_destroy_err(&ret)) return ret; pthread_mutex_lock(&srq->mutex); @@ -1559,11 +1579,16 @@ int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, int ibv_cmd_destroy_ah(struct ibv_ah *ah) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_DESTROY_AH); + int ret; *req = (struct ib_uverbs_destroy_ah){ .ah_handle = ah->handle, }; - return execute_write(ah->context, req, NULL); + ret = execute_write(ah->context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_destroy_qp(struct ibv_qp *qp) @@ -1576,7 +1601,7 @@ int ibv_cmd_destroy_qp(struct ibv_qp *qp) }; ret = execute_write(qp->context, req, &resp); - if (ret) + if (verbs_is_destroy_err(&ret)) return ret; pthread_mutex_lock(&qp->mutex); @@ -1602,13 +1627,18 @@ int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t l int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid) { DECLARE_LEGACY_CORE_REQ(IB_USER_VERBS_CMD_DETACH_MCAST); + int ret; *req = (struct ib_uverbs_detach_mcast){ .qp_handle = qp->handle, .mlid = lid, }; memcpy(req->gid, gid->raw, sizeof(req->gid)); - return execute_write(qp->context, req, NULL); + ret = execute_write(qp->context, req, NULL); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } static int buffer_is_zero(char *addr, ssize_t size) @@ -1869,11 +1899,16 @@ err: int ibv_cmd_destroy_flow(struct ibv_flow *flow_id) { DECLARE_LEGACY_CORE_BUFS_EX(IB_USER_VERBS_EX_CMD_DESTROY_FLOW); + int ret; *req = (struct ib_uverbs_destroy_flow){ .flow_handle = flow_id->handle, }; - return execute_write_ex(flow_id->context, req); + ret = execute_write_ex(flow_id->context, req); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } int ibv_cmd_create_wq(struct ibv_context *context, @@ -1976,7 +2011,7 @@ int ibv_cmd_destroy_wq(struct ibv_wq *wq) }; ret = execute_write_ex(wq->context, req); - if (ret) + if (verbs_is_destroy_err(&ret)) return ret; if (resp.response_length < sizeof(resp)) @@ -2046,11 +2081,16 @@ int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table) { DECLARE_LEGACY_CORE_BUFS_EX(IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL); + int ret; *req = (struct ib_uverbs_ex_destroy_rwq_ind_table){ .ind_tbl_handle = rwq_ind_table->ind_tbl_handle, }; - return execute_write_ex(rwq_ind_table->context, req); + ret = execute_write_ex(rwq_ind_table->context, req); + if (verbs_is_destroy_err(&ret)) + return ret; + + return 0; } diff --git a/libibverbs/cmd_cq.c b/libibverbs/cmd_cq.c index 0f4780a..73cd2f2 100644 --- a/libibverbs/cmd_cq.c +++ b/libibverbs/cmd_cq.c @@ -171,7 +171,7 @@ int ibv_cmd_destroy_cq(struct ibv_cq *cq) break; } - if (ret) + if (verbs_is_destroy_err(&ret)) return ret; pthread_mutex_lock(&cq->mutex);