From patchwork Thu Dec 17 14:18:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979839 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0952C2BB9A for ; Thu, 17 Dec 2020 14:20:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BEE2238EF for ; Thu, 17 Dec 2020 14:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbgLQOUA (ORCPT ); Thu, 17 Dec 2020 09:20:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbgLQOT7 (ORCPT ); Thu, 17 Dec 2020 09:19:59 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E2EC0617A7 for ; Thu, 17 Dec 2020 06:19:19 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id n26so38076441eju.6 for ; Thu, 17 Dec 2020 06:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5W1ywusO6gzyPssMkp8rV1kV/3FoZ1vU82I0QG9hg9k=; b=jK3u0VNKylkngCgrEA8HEaDmF4zZsasg6CmOK6oMS+jZMb/TwSGJ+FfUldbo1vnKgP JfmaRq7esW8kH9/kO9uZhiQ1aL/zRDcRI0VZoLSIsY1KRbIEDeFRE209YAIHH0UsGLi5 k1E6m1sU1PMct3J2lvJKRc9KjX/4mUzP1fnoG9szTRFKadhgfc84qd9L2YA4hh20gZBD W873Mbhgoj6xQi68++CmHHEcZMeeSCrIr020/LakLROhqS+d5E3S7Lj5tTeCWTUr9ZF0 AFTdF82JpWJbxUp1hHL9XusTXTiN+I5ZRAxL/eB60TPBd0t3GSvbrL1r9w3nOFi8Qkvw UctQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5W1ywusO6gzyPssMkp8rV1kV/3FoZ1vU82I0QG9hg9k=; b=JHhxDSnm2hC6BXYlIe1CurguXMFETk27tqeLtNmvRm0dGksSbRouv2tx73kC+ueJTr B4XTW3UMnlsVnGjFFAHCsKO7sLGq7WKpTYEHxHdcPpkYiRorCvWuOYM8McrERVoxGhuN larLiCcPntjn2mbvq7+B65f2NwfEz7JQRCLA9qrXFL1yzAnVdPbe9nGFNlG06MPfmkee QeIqAADkxT4o9dHwd0mJjzJCSJLRE8BkM7ntCVWQUIi8s7GpWQxub0aMkvazi4D86+3A dFxnTHFnDpk148honsLYhVUwa8ba5zYhPGIlwIb24P4uac1S+ktBV6hr+2m7ZMNokNtC SZLA== X-Gm-Message-State: AOAM530svSgdGZkk43EXRUBBvtoVT2hm+rmEu/WrpwckuLHHlw9pl4RM Ske8BQZ1tP9TSSl7LDJicwt9lWDHT8SE4g== X-Google-Smtp-Source: ABdhPJzK4x1x9K+6Sn2QQfGqT6WZ8MgtdPdT8uSvJcR777vM21n68vOmqYciRJ6NbmZoPIYJk9cDuw== X-Received: by 2002:a17:906:fa82:: with SMTP id lt2mr35511415ejb.322.1608214757852; Thu, 17 Dec 2020 06:19:17 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:17 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal Subject: [PATCHv2 for-next 01/19] RDMA/rtrs: Extend ibtrs_cq_qp_create Date: Thu, 17 Dec 2020 15:18:57 +0100 Message-Id: <20201217141915.56989-2-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org rtrs does not have same limit for both max_send_wr and max_recv_wr, To allow client and server set different values, export in a separate parameter for rtrs_cq_qp_create. Also fix the type accordingly, u32 should be used instead of u16. Fixes: c0894b3ea69d ("RDMA/rtrs: core: lib functions shared between client and server modules") Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++-- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 5 +++-- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++-- drivers/infiniband/ulp/rtrs/rtrs.c | 14 ++++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 67f86c405a26..719254fc83a1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1511,7 +1511,7 @@ static void destroy_con(struct rtrs_clt_con *con) static int create_con_cq_qp(struct rtrs_clt_con *con) { struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - u16 wr_queue_size; + u32 wr_queue_size; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1573,7 +1573,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, cq_vector, wr_queue_size, wr_queue_size, - IB_POLL_SOFTIRQ); + wr_queue_size, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, * since destroy_con_cq_qp() must be called. diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index 3f2918671dbe..d5621e6fad1b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -303,8 +303,9 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe, struct ib_send_wr *head); int rtrs_cq_qp_create(struct rtrs_sess *rtrs_sess, struct rtrs_con *con, - u32 max_send_sge, int cq_vector, u16 cq_size, - u16 wr_queue_size, enum ib_poll_context poll_ctx); + u32 max_send_sge, int cq_vector, int cq_size, + u32 max_send_wr, u32 max_recv_wr, + enum ib_poll_context poll_ctx); void rtrs_cq_qp_destroy(struct rtrs_con *con); void rtrs_init_hb(struct rtrs_sess *sess, struct ib_cqe *cqe, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index c42fd470c4eb..ed4628f032bb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1586,7 +1586,7 @@ static int create_con(struct rtrs_srv_sess *sess, struct rtrs_sess *s = &sess->s; struct rtrs_srv_con *con; - u16 cq_size, wr_queue_size; + u32 cq_size, wr_queue_size; int err, cq_vector; con = kzalloc(sizeof(*con), GFP_KERNEL); @@ -1630,7 +1630,8 @@ static int create_con(struct rtrs_srv_sess *sess, /* TODO: SOFTIRQ can be faster, but be careful with softirq context */ err = rtrs_cq_qp_create(&sess->s, &con->c, 1, cq_vector, cq_size, - wr_queue_size, IB_POLL_WORKQUEUE); + wr_queue_size, wr_queue_size, + IB_POLL_WORKQUEUE); if (err) { rtrs_err(s, "rtrs_cq_qp_create(), err: %d\n", err); goto free_con; diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 2e3a849e0a77..df52427f1710 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -231,14 +231,14 @@ static int create_cq(struct rtrs_con *con, int cq_vector, u16 cq_size, } static int create_qp(struct rtrs_con *con, struct ib_pd *pd, - u16 wr_queue_size, u32 max_sge) + u32 max_send_wr, u32 max_recv_wr, u32 max_sge) { struct ib_qp_init_attr init_attr = {NULL}; struct rdma_cm_id *cm_id = con->cm_id; int ret; - init_attr.cap.max_send_wr = wr_queue_size; - init_attr.cap.max_recv_wr = wr_queue_size; + init_attr.cap.max_send_wr = max_send_wr; + init_attr.cap.max_recv_wr = max_recv_wr; init_attr.cap.max_recv_sge = 1; init_attr.event_handler = qp_event_handler; init_attr.qp_context = con; @@ -260,8 +260,9 @@ static int create_qp(struct rtrs_con *con, struct ib_pd *pd, } int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, - u32 max_send_sge, int cq_vector, u16 cq_size, - u16 wr_queue_size, enum ib_poll_context poll_ctx) + u32 max_send_sge, int cq_vector, int cq_size, + u32 max_send_wr, u32 max_recv_wr, + enum ib_poll_context poll_ctx) { int err; @@ -269,7 +270,8 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, if (err) return err; - err = create_qp(con, sess->dev->ib_pd, wr_queue_size, max_send_sge); + err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, + max_send_sge); if (err) { ib_free_cq(con->cq); con->cq = NULL; From patchwork Thu Dec 17 14:18:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979845 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01CDAC2BBCA for ; Thu, 17 Dec 2020 14:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A47FA2395A for ; Thu, 17 Dec 2020 14:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727786AbgLQOUB (ORCPT ); Thu, 17 Dec 2020 09:20:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbgLQOUA (ORCPT ); Thu, 17 Dec 2020 09:20:00 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3442FC0617B0 for ; Thu, 17 Dec 2020 06:19:20 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id j22so20121170eja.13 for ; Thu, 17 Dec 2020 06:19:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8XPsxXHpszxd63HxIjgzTJhXEGSxw+1lsDSBnkcjABc=; b=TJvw/QhaoiXwTKVokg9Hn1muk2JMizYT+nn0x7X6ke3a6P+BbuZRkJU5uGDswuDiBk jTN/rekHr22C8C/vrL/iS6U+CVXuKxO8J/2atpqY5Fom7VGAe1lMd+/+IvG+5WV38wOH VAkcoW+6k7ZPuPrXyK1/FAnEbbvLC44AXe7q9f+cxlqOLzfgPdbWsYShXwMgcBc7A/Uz 0+3B6rvDnJ7r7uOKiuZehwFsWzzzeepjIfJkiyAAILOynraBgme6Ey2wsixINcgvdN8o w+46p7sfxdC1dL7Jnc2UkxpYghl3BuDrD2aLQXoMYgh69/JHzvN6XhV+GGdYcPaeOOEN ATIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8XPsxXHpszxd63HxIjgzTJhXEGSxw+1lsDSBnkcjABc=; b=I7yZEQHBpURrtcKfdYxF9cBYrOlFPmWFUdPb1narDHlKFxpye23IhoSN3kzMBOFqC6 KvabwIOROAR2w9UJJZ4S9dWFG7bG34NddWeBhJtIbYmCoR5at4hr+t+GNdbQsU5eg2+z tDuWkfibmx7jLaEq2pHHFyOGfouPBE/hqgnHbZLiDbBKhB/nVNtvhLOozA5S+/8nmLyD JhO4cpcQt2byYN1QkBLkOOv/pgXBtSmVEwO+mRimmKncZxaoQJfx+CX7Fn/yIykMBNm9 5r7d3uT/mONblhZDSnCGEC/7rJ9PORnjgSFEMuNWBjYjTgQFp7nB1OlJtOxft//JWOUL afTw== X-Gm-Message-State: AOAM532ckAeyI3e4MKt45Y4raw6ZZiUk1po07Bv3M28CaZK5Buv9ceZU vUnaczATOnuOAiBo9ZU2KRL6iE2GNqYsbw== X-Google-Smtp-Source: ABdhPJzMRb3zcDBpp9SlBitAV1SRCChTVEnoBt9GmIaJpFJBtfRL+A004GOsFfr6GvnO3RqS84Ru5w== X-Received: by 2002:a17:907:2052:: with SMTP id pg18mr3225734ejb.153.1608214758800; Thu, 17 Dec 2020 06:19:18 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:18 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 02/19] RMDA/rtrs-srv: Occasionally flush ongoing session closing Date: Thu, 17 Dec 2020 15:18:58 +0100 Message-Id: <20201217141915.56989-3-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org If there are many establishments/teardowns, we need to make sure we do not consume too much system memory. Thus let on going session closing to finish before accepting new connection. In cma_ib_req_handler, the conn_id is newly created holding handler_mutex when call this function, and flush_workqueue wait for close_work to finish, in close_work rdma_destroy_id will be called, which will hold the handler_mutex, but they are mutex for different rdma_cm_id. To avoid circular locking lockdep warnings, disable lockdep around flush_workqueue in rtrs_rdma_connect, it's false positive. Inspired by commit 777dc82395de ("nvmet-rdma: occasionally flush ongoing controller teardown") Signed-off-by: Jack Wang Reviewed-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index ed4628f032bb..eb7bb93884e7 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1791,6 +1791,20 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, err = -ENOMEM; goto reject_w_err; } + if (!cid) { + /* Let inflight session teardown complete * + * + * Avoid circular locking lockdep warnings. + * cma_ib_req_handler, the conn_id is newly created holding + * handler_mutex when call this function, and flush_workqueue + * wait for close_work to finish, in close_work rdma_destroy_id + * will be called, which will hold the handler_mutex, but they + * are mutex for different rdma_cm_id. + */ + lockdep_off(); + flush_workqueue(rtrs_wq); + lockdep_on(); + } mutex_lock(&srv->paths_mutex); sess = __find_sess(srv, &msg->sess_uuid); if (sess) { From patchwork Thu Dec 17 14:18:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979841 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 219B8C2BB48 for ; Thu, 17 Dec 2020 14:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDDF82389F for ; Thu, 17 Dec 2020 14:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbgLQOUC (ORCPT ); Thu, 17 Dec 2020 09:20:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728000AbgLQOUB (ORCPT ); Thu, 17 Dec 2020 09:20:01 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0A8C06138C for ; Thu, 17 Dec 2020 06:19:21 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id ce23so38100817ejb.8 for ; Thu, 17 Dec 2020 06:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uiAG3vHJfCPtvFvsfPnvqumtSywWdt9OJJe0oVLwKsU=; b=Y/Ve8M2wKfE7KT/GRVY3XCvd/cwrjFIjyvccvG3cBV+o/OL4iaASMv7Qu9QkTyHJuM RT0Cuight089c8G+1enfHlmcGbCh47qygA7l81d0Ak+ImX07vA/mPwiHRFMs9bPfLq06 0OrJM0C0Y5vCNBhYL03Qj3hD3eWCEd0jWVviiOcJt9d9Cy0nfa2B2Eg/+znOj1LNLcqF bd75D0wdsS+4AqYlxDv/ZgqlV4Eztm8TKlC6D8UUp30/+ZaPLjDwLm0M/CXEwAtFn9eg IAGajLrhIK+K/16vqZE8eibruVf2zM/kc8E/zcm2Vs+/2llbr2wOsNHhsGaTq1iXay9s 9blg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uiAG3vHJfCPtvFvsfPnvqumtSywWdt9OJJe0oVLwKsU=; b=quwSgpxfHYp6vAzGiDYLHxM3RlRYdeiLq5ureGW181TQ+zi85HmtdzyZOIwGPpVlK1 QGYEQMsw2AtYR/tM60sENe7wf/CrgWdu/thh1/BdA/TiSxCRHbD00fmtpldrx+r2Fnr9 in0g6SdIPs2ppF7ocAOd3ojvwXltrX2gLznsK1CiOUo7TabHPWqLc6Sv6Mwz37n6g9kp +IKV9NpoOAwumjHJplXbEWvZSMSXySZ2AsNROaskQo3W7MotBAHJ5BqAAnXv2kMT6Nzl LvUihse2uphqYyWYs9p5AGaQPIEVYGqyjQYXX/MPN7BjdjY4FIwASruCviUWW+Rpyh/L kylQ== X-Gm-Message-State: AOAM532G44iQNRiBtUuNzNKJZ73uYluS+GLMw/qVZnXl+GpCgpVhnsXc EfLecRY2IMIEyzdClyzS7vP6P0bkKEuvfQ== X-Google-Smtp-Source: ABdhPJyJ+oVfOibx3WzUY1Trlav90bngOWAUY2lrnKObSKQdhBJrss7Z/BYYDOkADcSPyXuVmdOQNQ== X-Received: by 2002:a17:906:fa12:: with SMTP id lo18mr36109793ejb.354.1608214760023; Thu, 17 Dec 2020 06:19:20 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:19 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Lutz Pogrell Subject: [PATCHv2 for-next 03/19] RDMA/rtrs-srv: Release lock before call into close_sess Date: Thu, 17 Dec 2020 15:18:59 +0100 Message-Id: <20201217141915.56989-4-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org In this error case, we don't need hold mutex to call close_sess. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Tested-by: Lutz Pogrell --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index eb7bb93884e7..6771fb4a1110 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1877,8 +1877,8 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, return rtrs_rdma_do_reject(cm_id, -ECONNRESET); close_and_return_err: - close_sess(sess); mutex_unlock(&srv->paths_mutex); + close_sess(sess); return err; } From patchwork Thu Dec 17 14:19:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979843 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51D6DC2BBCD for ; Thu, 17 Dec 2020 14:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0076E238EF for ; Thu, 17 Dec 2020 14:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728111AbgLQOUD (ORCPT ); Thu, 17 Dec 2020 09:20:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728000AbgLQOUC (ORCPT ); Thu, 17 Dec 2020 09:20:02 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5136CC061282 for ; Thu, 17 Dec 2020 06:19:22 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id 6so23453478ejz.5 for ; Thu, 17 Dec 2020 06:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f9TWG8KQ8txS78V+DUzYfWia1D89TVANkKX4YMXo1ZM=; b=Zq7bH1Tu00GDsCk0aXQJItNIGk52iM0sSW1YQ0LBgHH846FR/l6QcbE8pDAafTUUKl 8GZdBfXw+M+/29Oneo09NjOVjgunygKh5XTtZeZL2AYa//8vd9bHDSWssK20Kt9py9tu zzVgKrYkX1wEYfyawKtiD6+F+P2bj8GL2huKMddqfHmcijQw9AvBaa9mBXSj0Ly6fjIZ oztmY75VoCuQ/iP6qG5xE7UXOHGHcVxrcwJJKztTR8W9+CFs3S6yIeGkTxTPCpUDEpst s3hsJwzEysiQCovr1nrd5clirJSvn1FUaKCVqSwduezWp2lluF3KdqXakMWuvMIUyhLF +h5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f9TWG8KQ8txS78V+DUzYfWia1D89TVANkKX4YMXo1ZM=; b=j/dV8xpsr2iGv6qiyHTlO876zeBN69RMUQlYznxWg/2Et6Wt4z8cz0jzRYqjcm8kmM 0Xk5FIXfwypcJCrC4n4ODeqXyuOG59SEWqtF9pGlhmXiZQsPobavIUjfOUUoGeFtJU6o JWurOs3f2bAFK5PwhFGN431JMn/F3RuAT37pSJIo40xbh26gz1eG3ReJtWUXiiYg9qEx RenTbqjomBjA7QNgK2IEStNBXwkoLinJiHBYkUroi23ltbLo7dhgAgLFHSuHIuUbqKpr bY9XNCFm45t/e9cOrHh/Xg4lWe1g2mzGdT+ohOva+xZZhnIi8hyYr8pF4dRrarOYYQRm FYxw== X-Gm-Message-State: AOAM530ZYgcnVmxmPsiFON7la2tMZ0TNUSq71O3Hpe3Ki3DLNWalk8oF tEetSuS4Y7MbiYuTTRo3WDGaNBHeX5xAUw== X-Google-Smtp-Source: ABdhPJzH1t46URpmABcUEc//u5p0knXbhnJvsal/yvvQRvFqHQLUlt6dS4/FWEgVyCgGi8ZkwEjwUw== X-Received: by 2002:a17:906:ae14:: with SMTP id le20mr36238349ejb.451.1608214760948; Thu, 17 Dec 2020 06:19:20 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:20 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Lutz Pogrell Subject: [PATCHv2 for-next 04/19] RDMA/rtrs-srv: Use sysfs_remove_file_self for disconnect Date: Thu, 17 Dec 2020 15:19:00 +0100 Message-Id: <20201217141915.56989-5-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Remove self first to avoid deadlock, we don't want to use close_work to remove sess sysfs. Fixes: 91b11610af8d ("RDMA/rtrs: server: sysfs interface functions") Signed-off-by: Jack Wang Tested-by: Lutz Pogrell --- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index d2edff3b8f0d..cca3a0acbabc 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -51,6 +51,8 @@ static ssize_t rtrs_srv_disconnect_store(struct kobject *kobj, sockaddr_to_str((struct sockaddr *)&sess->s.dst_addr, str, sizeof(str)); rtrs_info(s, "disconnect for path %s requested\n", str); + /* first remove sysfs itself to avoid deadlock */ + sysfs_remove_file_self(&sess->kobj, &attr->attr); close_sess(sess); return count; From patchwork Thu Dec 17 14:19:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979847 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3B3AC4361B for ; Thu, 17 Dec 2020 14:20:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF667238EF for ; Thu, 17 Dec 2020 14:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgLQOUk (ORCPT ); Thu, 17 Dec 2020 09:20:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbgLQOUj (ORCPT ); Thu, 17 Dec 2020 09:20:39 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C03FC061285 for ; Thu, 17 Dec 2020 06:19:23 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id b2so28834796edm.3 for ; Thu, 17 Dec 2020 06:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cwr31r9xVs6HYLbvddJ5+hEwG5tfmVS3LWgeJk4fqjQ=; b=PpqAfLHCAvlmnS5JjNrMY/6s1cf+6ltv3fGoq8NU8VYYSBt+qlaNCUdhWk+S4C2yRb rDomAG0aYMvBxDrvWXNO6um+Dn+DKJ0KJeNLeI5IWpLl8smlP7syl3WC6KVunw0ll38s 06dj3uMqSVBJJ9AuNqsJztPB/U1kIE52XGC9YciAQ4SBW92X476AJJvL44NaDN552HE5 lUk6Bw2GbgJ0KYr8oISf4a+4B2WyqC+mMeltvkblSYkHbIWqQBW//MGcbUusVTbbMBBn 062lvUwus/b+PUsr1/voCcrtEEGqpz14yEypuXoDXEvASz7sHga/6zaS9KP9GV11B+Tz elMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cwr31r9xVs6HYLbvddJ5+hEwG5tfmVS3LWgeJk4fqjQ=; b=ZFYGqbpcXnG787h3vz55+sMGGwpZfbHRoEEFNU9kra8dIhhJ+ianjj2eJZ9sSDcqVM PW+ivMpm7K1OP7iEKpfFJmbAG2tqgVj1204iOQlubKKIGPm11PSADQHivqIalgETm/PB lmK4rM1NqSDKdhEgQnKwjY28R/maAZ+gGr6GqivaWJvQL78EBaR9ekUNvSHdiV7RdZXJ XvfYDASuiewy+jusuypStQywgCZR4jb+pDuwNFTtJe8HkBzV6CLYbGgJy1qus0EsKSHh U7FBAG+xzB4P+HyE6L33VkTFvYoSSt2f6Fzz6ifsbRsASS/38O4N/zD0RAFgihaoQuBd PSrA== X-Gm-Message-State: AOAM533DWXDjtUvgCLg/4QAHKpGJYdTA12jkyU4A+Nt5xXR+0mdIAtF8 L5/7yKKA0upgj3aLbKFbOFZjctUuOZYKew== X-Google-Smtp-Source: ABdhPJyWbYuBdybVbpivKLPJgmTHWoZHfiN6PovzqZ7VSL4Jn93Q74ng9H/xD/b+7jdbax7g5E4S4Q== X-Received: by 2002:a50:fc13:: with SMTP id i19mr39777345edr.281.1608214761816; Thu, 17 Dec 2020 06:19:21 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:21 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal Subject: [PATCHv2 for-next 05/19] RDMA/rtrs-clt: Set mininum limit when create QP Date: Thu, 17 Dec 2020 15:19:01 +0100 Message-Id: <20201217141915.56989-6-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Currently rtrs when create_qp use a coarse numbers (bigger in general), which leads to hardware create more resources which only waste memory with no benefits. - SERVICE con, For max_send_wr/max_recv_wr, it's 2 times SERVICE_CON_QUEUE_DEPTH + 2 - IO con For max_send_wr/max_recv_wr, it's sess->queue_depth * 3 + 1 Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 719254fc83a1..b3fb5fb93815 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1511,7 +1511,7 @@ static void destroy_con(struct rtrs_clt_con *con) static int create_con_cq_qp(struct rtrs_clt_con *con) { struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - u32 wr_queue_size; + u32 max_send_wr, max_recv_wr, cq_size; int err, cq_vector; struct rtrs_msg_rkey_rsp *rsp; @@ -1523,7 +1523,8 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) * + 2 for drain and heartbeat * in case qp gets into error state */ - wr_queue_size = SERVICE_CON_QUEUE_DEPTH * 3 + 2; + max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; + max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2; /* We must be the first here */ if (WARN_ON(sess->s.dev)) return -EINVAL; @@ -1555,25 +1556,29 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) /* Shared between connections */ sess->s.dev_ref++; - wr_queue_size = + max_send_wr = min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, /* QD * (REQ + RSP + FR REGS or INVS) + drain */ sess->queue_depth * 3 + 1); + max_recv_wr = + min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr, + sess->queue_depth * 3 + 1); } /* alloc iu to recv new rkey reply when server reports flags set */ if (sess->flags == RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { - con->rsp_ius = rtrs_iu_alloc(wr_queue_size, sizeof(*rsp), + con->rsp_ius = rtrs_iu_alloc(max_recv_wr, sizeof(*rsp), GFP_KERNEL, sess->s.dev->ib_dev, DMA_FROM_DEVICE, rtrs_clt_rdma_done); if (!con->rsp_ius) return -ENOMEM; - con->queue_size = wr_queue_size; + con->queue_size = max_recv_wr; } + cq_size = max_send_wr + max_recv_wr; cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors; err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge, - cq_vector, wr_queue_size, wr_queue_size, - wr_queue_size, IB_POLL_SOFTIRQ); + cq_vector, cq_size, max_send_wr, + max_recv_wr, IB_POLL_SOFTIRQ); /* * In case of error we do not bother to clean previous allocations, * since destroy_con_cq_qp() must be called. From patchwork Thu Dec 17 14:19:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979849 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42D92C2BB9A for ; Thu, 17 Dec 2020 14:20:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13AF8238EF for ; Thu, 17 Dec 2020 14:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728117AbgLQOUk (ORCPT ); Thu, 17 Dec 2020 09:20:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727246AbgLQOUj (ORCPT ); Thu, 17 Dec 2020 09:20:39 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16376C061248 for ; Thu, 17 Dec 2020 06:19:24 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id cm17so28824678edb.4 for ; Thu, 17 Dec 2020 06:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HaKGDnuifTU5L5KLU2Tpj7+tCZ+lTyDwJG4jK//u6Sk=; b=VI+ekysY4Vx41AFO01ZJU5eGxwCcFIAMDyXbUo1DeHj9YKE8C8PHcD6ryt0eKBjqxr TVBDQ6TFrFSenbDgtY/XVFAKi3n0CKBST4AR+hO6YXgoBVMsM7AU4jMbYAbIDCxawZuB BHxb28kt4TW0SEkWQTRi9+beSNJh6vuFXZWwWHmWjjabNFjWSQH7I0ZaSjFqiixP+LHA 4Mbn/0cIbV986P65L4+4M3nAtkqRjE/ozfmneguTgjk+DcipcNWqif/cAsVDmq5FFOeP sI1i7kc8lnt/SAt/KlanMr5FAJyfh+eOkhanJ1iEZ1DMOndbExaQkVE7ZBy9oXYVzvGI z9mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HaKGDnuifTU5L5KLU2Tpj7+tCZ+lTyDwJG4jK//u6Sk=; b=gijEVexpUjPTKPdcyD/ZtmH9heEbEPFtWsHqtpDo9lL3iGSt0mPlmU+F+B0OsZWVcp SUkiDiDmOOJiFd2QorjLynj4jbnGJ9CXESdIQYoIa/jQ43kwasxNtqnSAI2AGX7OxfpW 4bk30RvaC7W0bbmW1BCMGrD+1EZ88m0X0Tq4QkrfXX9HmZce8hO3GWoX1L5TqCnhmZHt LFJGgJye17kVJFf/JDCkYFWK72LZby8u9r6yeZa8GuWE5IzLPEVXxOy5MhIjlF2xfQzr iPLwZfmhgm87aQ5wh3QhgegYaaDe93RAfkFKpfa2ZtjwVAnypgRsHwfaueKSb8ZSsEV/ m3pg== X-Gm-Message-State: AOAM530m3DG4tSMPn6v+82+DzUEqOEGngfukP74z9V8fbCo+X22OfqQI AfgpbErqm4DsE/8pnERxlFxmQlbl3mtAlg== X-Google-Smtp-Source: ABdhPJx3pjmlYhdC7oA9AoMCKKRqBll3MHb4SDGbfUe0roHhv7Tn28oMxB/A0bszVddsNe/IDSLyig== X-Received: by 2002:aa7:d485:: with SMTP id b5mr37568150edr.214.1608214762707; Thu, 17 Dec 2020 06:19:22 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:22 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Gioh Kim Subject: [PATCHv2 for-next 06/19] RDMA/rtrs-srv: Jump to dereg_mr label if allocate iu fails Date: Thu, 17 Dec 2020 15:19:02 +0100 Message-Id: <20201217141915.56989-7-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang The rtrs_iu_free is called in rtrs_iu_alloc if memory is limited, so we don't need to free the same iu again. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Guoqing Jiang Reviewed-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 6771fb4a1110..89e938a1a4fb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -651,7 +651,7 @@ static int map_cont_bufs(struct rtrs_srv_sess *sess) if (!srv_mr->iu) { err = -ENOMEM; rtrs_err(ss, "rtrs_iu_alloc(), err: %d\n", err); - goto free_iu; + goto dereg_mr; } } /* Eventually dma addr for each chunk can be cached */ @@ -667,7 +667,6 @@ static int map_cont_bufs(struct rtrs_srv_sess *sess) srv_mr = &sess->mrs[mri]; sgt = &srv_mr->sgt; mr = srv_mr->mr; -free_iu: rtrs_iu_free(srv_mr->iu, sess->s.dev->ib_dev, 1); dereg_mr: ib_dereg_mr(mr); From patchwork Thu Dec 17 14:19:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979855 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E9F7C2BB48 for ; Thu, 17 Dec 2020 14:20:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56307238EF for ; Thu, 17 Dec 2020 14:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728131AbgLQOUk (ORCPT ); Thu, 17 Dec 2020 09:20:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727260AbgLQOUk (ORCPT ); Thu, 17 Dec 2020 09:20:40 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BCD1C061257 for ; Thu, 17 Dec 2020 06:19:25 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id lt17so38115329ejb.3 for ; Thu, 17 Dec 2020 06:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=995sngWFQB2h3MQ9SRxKgslkNwFLet34t3ZGVlvVkz0=; b=NNq6ry0dEqj1QHy+s5KSp15ReMY5q2MpDsuIpg1YlWhzEBvHMcFZ8LfxNQn6SU9PBf hCUXfIgh1sSAp/vxVFJz+nh4RCwB/TnJil2QNPwtxR5ZYpBAmoM44VdWP0KumhCsJAqS o20or60urEb2Jbmot+knhoLl43Nwd8qq0oQqOzPOSGfsFdcSUYEP5uJ9xUShksqq0yPc 2wqHtnEH10EZ/An3/eOexxyEKS461HEyxd3xDV2TZIRS5QZOlABVeKizyAkWmjbLL/3i OuOiP72Sv10R+p/J9RtEaZRb++nPN3rJZ9XT1m7f2G+58/gHeQas3v0b+En5fBC/qyJ3 PJ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=995sngWFQB2h3MQ9SRxKgslkNwFLet34t3ZGVlvVkz0=; b=dPLdDJpty9pvmjF8ivxFh1fd+yPWSA5uXk6NhhPQTp8bimFqKxaTSIasKHRV5FhQW0 jkuNJfbF7pi+jsezeBVXZ0SiCRNHjywxTITeZ3Ui233P5n6Y3H0BTL+L+O0GE/cNHFts 3nnVs1vLN6FDpMe4Muq2wrjGEBjhSWaItgwqXPiTrLMZs+x/W00+tBEJ2q7AW220xWg+ /M7+9llbgyNecF/kYEPPueyC15dlv9Vilp8eOTqAEvc5KID5fbNwVV4Xmw+nDyKsJ6Dh QHy/bPBFWUhYWwu/8E4F7yk8EXWu2v3NMcfGrLxVMQ05NSZea10JYWqmO+VFnXafWOSz Wafg== X-Gm-Message-State: AOAM530rXjgi1lemp5/zbLc1FRkroPeIKlngL3wmYzVb5ozik8qS0eAd AWPyvWuCAzdPNiVe4+W1XvHbl9b3mgCUDg== X-Google-Smtp-Source: ABdhPJx3v8oDv3/66PDAF5Foc1nOoYkSi5hqI9K5oGqnhmkQJDmhsHthgaUAvz7BnnxrvglNIBPIMw== X-Received: by 2002:a17:906:3b8b:: with SMTP id u11mr34820735ejf.489.1608214763658; Thu, 17 Dec 2020 06:19:23 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:23 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal , Gioh Kim Subject: [PATCHv2 for-next 07/19] RDMA/rtrs: Call kobject_put in the failure path Date: Thu, 17 Dec 2020 15:19:03 +0100 Message-Id: <20201217141915.56989-8-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Per the comment of kobject_init_and_add, we need to free the memory by call kobject_put. Fixes: 215378b838df ("RDMA/rtrs: client: sysfs interface functions") Fixes: 91b11610af8d ("RDMA/rtrs: server: sysfs interface functions") Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Reviewed-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 2 ++ drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index ba00f0de14ca..ad77659800cd 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -408,6 +408,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) "%s", str); if (err) { pr_err("kobject_init_and_add: %d\n", err); + kobject_put(&sess->kobj); return err; } err = sysfs_create_group(&sess->kobj, &rtrs_clt_sess_attr_group); @@ -419,6 +420,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) &sess->kobj, "stats"); if (err) { pr_err("kobject_init_and_add: %d\n", err); + kobject_put(&sess->stats->kobj_stats); goto remove_group; } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index cca3a0acbabc..0a3886629cae 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -236,6 +236,7 @@ static int rtrs_srv_create_stats_files(struct rtrs_srv_sess *sess) &sess->kobj, "stats"); if (err) { rtrs_err(s, "kobject_init_and_add(): %d\n", err); + kobject_put(&sess->stats->kobj_stats); return err; } err = sysfs_create_group(&sess->stats->kobj_stats, @@ -292,8 +293,8 @@ int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess) sysfs_remove_group(&sess->kobj, &rtrs_srv_sess_attr_group); put_kobj: kobject_del(&sess->kobj); - kobject_put(&sess->kobj); destroy_root: + kobject_put(&sess->kobj); rtrs_srv_destroy_once_sysfs_root_folders(sess); return err; From patchwork Thu Dec 17 14:19:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979853 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50129C2BBCD for ; Thu, 17 Dec 2020 14:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 289372395A for ; Thu, 17 Dec 2020 14:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbgLQOUl (ORCPT ); Thu, 17 Dec 2020 09:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727889AbgLQOUk (ORCPT ); Thu, 17 Dec 2020 09:20:40 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E63C0611C5 for ; Thu, 17 Dec 2020 06:19:25 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id q16so28785726edv.10 for ; Thu, 17 Dec 2020 06:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=81PSqEKTzeewp1eFw0SkbXHJmtuB6a/3wq15G2WR/5g=; b=UGSJK+TgAS6TFUfzUW4qLPGelqd549ZlCmWX3kFm4sFy5rag8aY17HFo1N/bBygJEQ oqGMwNI0FBwieo3oL3CgSTAGQyzecKrx7CH9sgMB2g4EssKar2Kvc54YiK69uBtSvPTu AjTMtXRpmMAt3DaFpcbQNtJd8864hhHLZ0gyqf4lKJFAHVdudTaxmwHMd2l1/279Py3U fpbtJi5zOlVX3sUbwQilcTxb3UL+MTAuJdLT3UUg/TTwgPkaqJg1Qc+owPIaHBPJdC5s 2sQ37jVkRuxYDCcKQcY0/dcxNNoUsxCFtTKm9IS8mvN+Yiwk8ZZiX9bb9c67Sivd4Evo 1wFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=81PSqEKTzeewp1eFw0SkbXHJmtuB6a/3wq15G2WR/5g=; b=CQ+aKc3iRdiykyYIwMXo9w+FHJBA76vY+RnQQY2ywQpYPIYG/1QUnUs0ege2R5wFkm w6YXKKAJnHMDBmfIwZ04eR2Lo/O24vhYmedjasr7D7O+Y22/L0haTTcIFCk/fyp6BbhH 9MYK/WWRHf+QKc7XOrUS42cucvOswu1MUWlCllv60dbYox8hpN5VkS08mzA5WHPrRNPr ljB7q7HZ3JnoOX5KdxJexs4zNnyTozNRRM5fJEkX70UaS3NjmwS9jxar4xI0lcCdd2go eWVuTAgUxuMi8Y4tvSTReW0aBxnHt7f6RkOYQukjA7SR1sLnemQizt0r35MBZyqVx6qz t8Hw== X-Gm-Message-State: AOAM532rV1fWIabG39fOl7VEzN/E0h+V3V+3nsNc7ps8ClndjFkrEFEP The9osPEQ/PiDIlpd110zJ274Yomyq+rkg== X-Google-Smtp-Source: ABdhPJyJWnpfhlyu5uZtqDnsMoKmZVBbDpnJe72U7OIX55AI7FzVA6/pXfp0zyNY7ZuZzLsAj8/rZQ== X-Received: by 2002:a05:6402:310f:: with SMTP id dc15mr38625528edb.225.1608214764515; Thu, 17 Dec 2020 06:19:24 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:24 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 08/19] RDMA/rtrs-clt: Consolidate rtrs_clt_destroy_sysfs_root_{folder,files} Date: Thu, 17 Dec 2020 15:19:04 +0100 Message-Id: <20201217141915.56989-9-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Since the two functions are called together, let's consolidate them in a new function rtrs_clt_destroy_sysfs_root. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 9 +++------ drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++---- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index ad77659800cd..b6a0abf40589 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -471,15 +471,12 @@ int rtrs_clt_create_sysfs_root_files(struct rtrs_clt *clt) return sysfs_create_group(&clt->dev.kobj, &rtrs_clt_attr_group); } -void rtrs_clt_destroy_sysfs_root_folders(struct rtrs_clt *clt) +void rtrs_clt_destroy_sysfs_root(struct rtrs_clt *clt) { + sysfs_remove_group(&clt->dev.kobj, &rtrs_clt_attr_group); + if (clt->kobj_paths) { kobject_del(clt->kobj_paths); kobject_put(clt->kobj_paths); } } - -void rtrs_clt_destroy_sysfs_root_files(struct rtrs_clt *clt) -{ - sysfs_remove_group(&clt->dev.kobj, &rtrs_clt_attr_group); -} diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index b3fb5fb93815..99fc34950032 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2707,8 +2707,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, rtrs_clt_close_conns(sess, true); kobject_put(&sess->kobj); } - rtrs_clt_destroy_sysfs_root_files(clt); - rtrs_clt_destroy_sysfs_root_folders(clt); + rtrs_clt_destroy_sysfs_root(clt); free_clt(clt); out: @@ -2725,8 +2724,7 @@ void rtrs_clt_close(struct rtrs_clt *clt) struct rtrs_clt_sess *sess, *tmp; /* Firstly forbid sysfs access */ - rtrs_clt_destroy_sysfs_root_files(clt); - rtrs_clt_destroy_sysfs_root_folders(clt); + rtrs_clt_destroy_sysfs_root(clt); /* Now it is safe to iterate over all paths without locks */ list_for_each_entry_safe(sess, tmp, &clt->paths_list, s.entry) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index b8dbd701b3cb..a97a068c4c28 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -243,8 +243,7 @@ ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *stats, /* rtrs-clt-sysfs.c */ int rtrs_clt_create_sysfs_root_files(struct rtrs_clt *clt); -void rtrs_clt_destroy_sysfs_root_folders(struct rtrs_clt *clt); -void rtrs_clt_destroy_sysfs_root_files(struct rtrs_clt *clt); +void rtrs_clt_destroy_sysfs_root(struct rtrs_clt *clt); int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess); void rtrs_clt_destroy_sess_files(struct rtrs_clt_sess *sess, From patchwork Thu Dec 17 14:19:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979851 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35445C2BBCA for ; Thu, 17 Dec 2020 14:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1100238EF for ; Thu, 17 Dec 2020 14:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbgLQOUl (ORCPT ); Thu, 17 Dec 2020 09:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbgLQOUl (ORCPT ); Thu, 17 Dec 2020 09:20:41 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8BBC0611CA for ; Thu, 17 Dec 2020 06:19:26 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id 6so23453839ejz.5 for ; Thu, 17 Dec 2020 06:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qy3ygq6w7O8DF53aV7q7DOLXGPF0OfN7MeSVY+w05wM=; b=B0TKE+vjtx+0BG3H7KiU4TJ/P1oBR+BobIQ8CKfnEq18l/s3dydiYC4EfnQWN2Me5B 5fcpLqXse7cjrec7GIAId5UgOoN0iydwF8MbXHFLY7wVvZNkDpiMdzGYdPhZ1lyS0WOt qBgp7nKn1abRJ8d08qYauDROnP1mWFZdQXWl9SudYUBprr863Y+jqnbNBGC0EejyTMbv qvwqlk89JPakKc3KuEGZa4fpSebYUkpscAX8cwfW+zgg9u38kfxxiH5K0wdRGLxHddXw 7v3WZXSBLYW8+rfbrk4ZulczH2wB6Y+w1vYtGeZpdyNrsZC55lA3l6soI592r7t/pbs5 Wlkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qy3ygq6w7O8DF53aV7q7DOLXGPF0OfN7MeSVY+w05wM=; b=PYikgmGs7OZ3DfbUuGOszQWAFe3Xu0upehLjSdh4PCkzmgqUarsrSBNDAvqszLJMKM d9YLSJGelxiH5Sq1Z7HjHZJbiiflWgYfcjmZBV2K+aDd2sTkpEo78JVp+a/s/YYaQHfw +2Ikf04GikLNNWxDkf5fW/O2iKdKqlloFrqtzUkys9gnEXHjCoTOXLQ8OZVsq+dWoaBF E8pBVINQX1flk3cXIuWucy+QlgX+3db0+PY4RofIpTeCLJU9zPO5C2AcDQ6Uo3pFG/oj QCXmFbEHE2WMpHo59ZpBo7rMtP29uEeLu4qJXRTjqsYaqoCd2zk15BhNUXGIcJ9Lql87 h3eQ== X-Gm-Message-State: AOAM533nhY7YlHaOTVmIDYHz9RHdINQyASDSYOqLbw1IW8k4jg1p65B/ nWrLwopRkcwX1fX4BMPOnwJZZCerypmR2Q== X-Google-Smtp-Source: ABdhPJzvgmmtd4lfNJ8Yr7gPJbFf9a2Bo3wd2EBQx0KMqpWa005lMFlCc3qvfX1d6tzwe4byfb7I9w== X-Received: by 2002:a17:906:ce2b:: with SMTP id sd11mr36357385ejb.334.1608214765452; Thu, 17 Dec 2020 06:19:25 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:25 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCHv2 for-next 09/19] RDMA/rtrs-clt: Kill wait_for_inflight_permits Date: Thu, 17 Dec 2020 15:19:05 +0100 Message-Id: <20201217141915.56989-10-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Let's wait the inflight permits before free it. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 99fc34950032..6a5b72ad5ba1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1318,6 +1318,12 @@ static int alloc_permits(struct rtrs_clt *clt) static void free_permits(struct rtrs_clt *clt) { + if (clt->permits_map) { + size_t sz = clt->queue_depth; + + wait_event(clt->permits_wait, + find_first_bit(clt->permits_map, sz) >= sz); + } kfree(clt->permits_map); clt->permits_map = NULL; kfree(clt->permits); @@ -2607,19 +2613,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, return clt; } -static void wait_for_inflight_permits(struct rtrs_clt *clt) -{ - if (clt->permits_map) { - size_t sz = clt->queue_depth; - - wait_event(clt->permits_wait, - find_first_bit(clt->permits_map, sz) >= sz); - } -} - static void free_clt(struct rtrs_clt *clt) { - wait_for_inflight_permits(clt); free_permits(clt); free_percpu(clt->pcpu_path); mutex_destroy(&clt->paths_ev_mutex); From patchwork Thu Dec 17 14:19:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979857 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF142C2BBCF for ; Thu, 17 Dec 2020 14:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DF81238EF for ; Thu, 17 Dec 2020 14:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728159AbgLQOUm (ORCPT ); Thu, 17 Dec 2020 09:20:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728143AbgLQOUl (ORCPT ); Thu, 17 Dec 2020 09:20:41 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1535C0611CB for ; Thu, 17 Dec 2020 06:19:27 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id b2so28835020edm.3 for ; Thu, 17 Dec 2020 06:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3RUukiGOKC64hIM5ZnyE1+UPMzjrvnMOxG9huIVLy+s=; b=cyvk4ONlbuLZren59o3vePOulE6fSjY4ydeDdtjmmjA4WdcgYzHJEGeWy/rwLAwdPg eWk6CHGdAnmsvHW24gQvBMnQlbx5Y7yEiKQ9ceJJCzrPQnsEt9RQMw9+djzfrY4K9Bzp P9D/BdgJQBxhkAFjaIR8K33NnDY7lue5h30ajtYUkdtcuuW5t8iShTrh59ZZr+I9HGLG D7WJjTyiiiLUg55h7z2b0EEos0J8XWNOJjrvYxqmsn+olNeeDIu5NZObT75vT9K0IpIE Opbkr08Dvyj09GbABgthYAQM/rI8dLuldRlED85Z5m9+OzmlfvMX4nexuCNdw8g8Yy9L eJjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3RUukiGOKC64hIM5ZnyE1+UPMzjrvnMOxG9huIVLy+s=; b=hFl/X6mKmWsb56NCobv97Z7MKQfV8OI0wrQgJSJ5LC8mmEcPxTPpwKCJckTXrmVjB5 7OkyqouEoGUaLaao6Db7yIqrDx20wwQFb4Izr6AmQw+oSE7mIdpknk0VtZj3Ss/m8Ju8 CLd/pcOSk5njXKbkSm2udyyTsWuyCE6Pa7B9xerudlpUoeylq2b9fCUZlD+C5Y4+qdqM X46YkHnSAt+gMBgQoXvgifzxK5T10pKp05ORdttGTBggat39AyadopmVHEnhmLmxsPQG iB+/BlmsJKX4he+eHGbyKvVneq3Odgkj5mOa221WqvKoes08EF759Sh52KSO8BFOj1rr 3/+Q== X-Gm-Message-State: AOAM531M4VsvZ4W1sw2vaU/obDBTRF2yEpXoe7T2yrrmk/ibRzdRUk6K 8tUWzc56uqjai2Xn//1Fx3Web9+WSBe1YA== X-Google-Smtp-Source: ABdhPJybPi0RaLJciyDOU6HShX2VgCj5ZGS0JTk5c5RJx/z5h+0+pnqHk7duox/1mMPCL0Dgrh7SVA== X-Received: by 2002:a05:6402:1d13:: with SMTP id dg19mr38710184edb.111.1608214766375; Thu, 17 Dec 2020 06:19:26 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:26 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 10/19] RDMA/rtrs-clt: Remove unnecessary 'goto out' Date: Thu, 17 Dec 2020 15:19:06 +0100 Message-Id: <20201217141915.56989-11-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang This is not needed since the label is just after the place. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 6a5b72ad5ba1..d99fb1a1c194 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2434,7 +2434,6 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) err = -ECONNRESET; else err = -ETIMEDOUT; - goto out; } out: From patchwork Thu Dec 17 14:19:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979859 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66729C2BBD5 for ; Thu, 17 Dec 2020 14:20:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27CB0238EF for ; Thu, 17 Dec 2020 14:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728305AbgLQOUm (ORCPT ); Thu, 17 Dec 2020 09:20:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728143AbgLQOUm (ORCPT ); Thu, 17 Dec 2020 09:20:42 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96516C0611CD for ; Thu, 17 Dec 2020 06:19:28 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id g24so3190605edw.9 for ; Thu, 17 Dec 2020 06:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K20am84mWdOPDtt/C3eABp6vABmQqQkIc3UUOw+LTjA=; b=CkwzMmS7VdxuoMezxc2GdrjESt9w/uxgcJJrwPh9t5FUcaDJSf8gMvO8N8uWAnNXwP 0qCcpwhBCsj7o3rgh0y79fiuO+iCAJ7VbUCp9j+tu/04jvvyO76vF2MmaEysanJKUfMk OXUJ8gJJsCH6UgqvLbjgO7GJxyW8eCRTdzhPkYKuWdbg+NKFdx1mS3uLULKAvdlBddwV pzL4B6EQUArGIc5/SjkMfSkwdmFYaXWkMURLjUiDLd7X6wg+CgyMk0UMFVErXxUpLTf6 7o3r8QSIuvg7nfwG3VSZrvNW/loY15VU8MOs+okeJqzXpG1JOfG2bKRcuwaKOq6wIDi6 k8yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K20am84mWdOPDtt/C3eABp6vABmQqQkIc3UUOw+LTjA=; b=dIX+hof7ZRKW/kkWfL0jKqq9Xa9CvIO3Rw46ZxdkdzwZVpaHCl0bqwurpQbo+VH6Ab 9Q4JLuJW/ONSuXdwWgMZkYPaVdhXOd0el0HnOCtsUEfu90BNxGNYo38AfGy4Fu7+OoPi PmoSt0Dpx+vkYZ/22bq97M6nyVNkr8G64HXMM3HJBccedBXUgL3KAq6fyuff4JsnH4Pe QIZxSyWe8bcbgNBDPZ4i9XNUf0ohfAFmwkT1RZwu5kzhji54GuAmh0YtzfplItLhbRpR qKfb1ZEYT4Pkl6055Rww6DzBql+dnPyVC7jkXjGdS9cA6++dBAhTuv0pztp2jqsSr8cQ KUNg== X-Gm-Message-State: AOAM533+OYWeSIa03sGWyKRFpb5K4HHGoBfEZcpnRFrh4U0qk9ab2gw7 U/puSjFb2gX3osrCU8zY4/IZe0joqbqlkg== X-Google-Smtp-Source: ABdhPJzFalV0eev3YCAgnYcJqGqhPvP+N3pdh3AGlLB1zdy0pyDdNVmzlFLGFZmvNN+e5XAFqV+bog== X-Received: by 2002:a50:9ea4:: with SMTP id a33mr11439540edf.70.1608214767171; Thu, 17 Dec 2020 06:19:27 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:26 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang Subject: [PATCHv2 for-next 11/19] RDMA/rtrs-clt: Kill rtrs_clt_change_state Date: Thu, 17 Dec 2020 15:19:07 +0100 Message-Id: <20201217141915.56989-12-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang It is just a wrapper of rtrs_clt_change_state_get_old, and we can reuse rtrs_clt_change_state_get_old with add the checking of 'old_state' is valid or not. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index d99fb1a1c194..39dc8423d7df 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1359,21 +1359,14 @@ static bool rtrs_clt_change_state_get_old(struct rtrs_clt_sess *sess, bool changed; spin_lock_irq(&sess->state_wq.lock); - *old_state = sess->state; + if (old_state) + *old_state = sess->state; changed = __rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; } -static bool rtrs_clt_change_state(struct rtrs_clt_sess *sess, - enum rtrs_clt_state new_state) -{ - enum rtrs_clt_state old_state; - - return rtrs_clt_change_state_get_old(sess, new_state, &old_state); -} - static void rtrs_clt_hb_err_handler(struct rtrs_con *c) { struct rtrs_clt_con *con = container_of(c, typeof(*con), c); @@ -1799,7 +1792,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, static void rtrs_clt_close_conns(struct rtrs_clt_sess *sess, bool wait) { - if (rtrs_clt_change_state(sess, RTRS_CLT_CLOSING)) + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_CLOSING, NULL)) queue_work(rtrs_wq, &sess->close_work); if (wait) flush_work(&sess->close_work); @@ -2185,7 +2178,7 @@ static void rtrs_clt_close_work(struct work_struct *work) cancel_delayed_work_sync(&sess->reconnect_dwork); rtrs_clt_stop_and_destroy_conns(sess); - rtrs_clt_change_state(sess, RTRS_CLT_CLOSED); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CLOSED, NULL); } static int init_conns(struct rtrs_clt_sess *sess) @@ -2237,7 +2230,7 @@ static int init_conns(struct rtrs_clt_sess *sess) * doing rdma_resolve_addr(), switch to CONNECTION_ERR state * manually to keep reconnecting. */ - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return err; } @@ -2254,7 +2247,7 @@ static void rtrs_clt_info_req_done(struct ib_cq *cq, struct ib_wc *wc) if (unlikely(wc->status != IB_WC_SUCCESS)) { rtrs_err(sess->clt, "Sess info request send failed: %s\n", ib_wc_status_msg(wc->status)); - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return; } @@ -2378,7 +2371,7 @@ static void rtrs_clt_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc) out: rtrs_clt_update_wc_stats(con); rtrs_iu_free(iu, sess->s.dev->ib_dev, 1); - rtrs_clt_change_state(sess, state); + rtrs_clt_change_state_get_old(sess, state, NULL); } static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) @@ -2443,7 +2436,7 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) rtrs_iu_free(rx_iu, sess->s.dev->ib_dev, 1); if (unlikely(err)) /* If we've never taken async path because of malloc problems */ - rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING_ERR); + rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING_ERR, NULL); return err; } @@ -2500,7 +2493,7 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) /* Stop everything */ rtrs_clt_stop_and_destroy_conns(sess); msleep(RTRS_RECONNECT_BACKOFF); - if (rtrs_clt_change_state(sess, RTRS_CLT_CONNECTING)) { + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_CONNECTING, NULL)) { err = init_sess(sess); if (err) goto reconnect_again; @@ -2509,7 +2502,7 @@ static void rtrs_clt_reconnect_work(struct work_struct *work) return; reconnect_again: - if (rtrs_clt_change_state(sess, RTRS_CLT_RECONNECTING)) { + if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_RECONNECTING, NULL)) { sess->stats->reconnects.fail_cnt++; delay_ms = clt->reconnect_delay_sec * 1000; queue_delayed_work(rtrs_wq, &sess->reconnect_dwork, From patchwork Thu Dec 17 14:19:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979865 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 936EBC2D0E4 for ; Thu, 17 Dec 2020 14:20:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60339238EF for ; Thu, 17 Dec 2020 14:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbgLQOUn (ORCPT ); Thu, 17 Dec 2020 09:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728325AbgLQOUn (ORCPT ); Thu, 17 Dec 2020 09:20:43 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F50BC0611CE for ; Thu, 17 Dec 2020 06:19:29 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id q22so20357532eja.2 for ; Thu, 17 Dec 2020 06:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNCE9BUjl8LjgBBWvrzQwpmCGHe5xlvz+eb/c5dap0o=; b=QrnQs7Y54xJMvr96TG9gQqczUbvHJ3KTZO8F4zbSTyaui9oMB0J1BjhW5g72EkSyZ8 aNRWMRR9pan0Z9FF37IS0X0wXiMbnbKbZY0RNzi7nLusAF8dcmwv0eScwGDXtalUhzOw oEyGW9N/hrxB4tQuU1CjD/4SoLjKciu0Zml/goSXI80xCp9dDWsvvd7XdFvzqbpssuHG y2OaZ9sCF8Q7r1xwiT0H9n9Z6BdXI+HH4UQrWbNiVLNbtKoKgp4+q5gMSa4v+piS17Ji iNHCQThvkkUojxnCSCFxCEAWU0jdBtjC5Ht1McdDnf/GCb5G8/vg/8Wzu9wsjoYK4x8P LQVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TNCE9BUjl8LjgBBWvrzQwpmCGHe5xlvz+eb/c5dap0o=; b=ZZSkB7rkJL8JbdmNcpylGzFVKmP2owvxBeHCJhdIJMyO03kZ9xzY18aWKD7z2xH8eX /fnV5K+TIhg25lheuuvw+NVdbl799dz5hpWBAyi04uYsWySnD90VgbAYvTl5T1ozrE0F dMCD2XxiQ5sCkWzRpzrxD6QOHcuF28ZsEXZNwj+tPvw3//rK6w5MeDgPLTBObR0mjd5M za5ut2vFAWzAfnoanPklqVFgluU6uxpARM5OY9RUdMXqhWZrs+MPZktiwJaj1GEaHS0p 4hLSYSJ9/9qyb6F/yjUkB0SW5i/FiAqNuVgVWxoFudslQgEJ7PjfZ5TivRLA8gRmOP1B 8z1g== X-Gm-Message-State: AOAM530YvsBaNS091SSQG37mk7bApZgd5Jo4IlzHuljaHhycUIo+Yg7u YBdScc8MhzTQaxIuFvbxCUgDIE3syIaOSA== X-Google-Smtp-Source: ABdhPJwVn3FqGPKqdoQX/e0Kjg54CQx/0vyVx4e/3C6ZfGZFCYuFqHIwJY+Kl0oiha5Ooo2HUuSxhg== X-Received: by 2002:a17:907:28d4:: with SMTP id en20mr36076722ejc.196.1608214768145; Thu, 17 Dec 2020 06:19:28 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:27 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCHv2 for-next 12/19] RDMA/rtrs-clt: Rename __rtrs_clt_change_state to rtrs_clt_change_state Date: Thu, 17 Dec 2020 15:19:08 +0100 Message-Id: <20201217141915.56989-13-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Let's rename it to rtrs_clt_change_state since the previous one is killed. Also update the comment to make it more clear. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 39dc8423d7df..3c90718f668d 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -178,18 +178,18 @@ struct rtrs_clt_con *rtrs_permit_to_clt_con(struct rtrs_clt_sess *sess, } /** - * __rtrs_clt_change_state() - change the session state through session state + * rtrs_clt_change_state() - change the session state through session state * machine. * * @sess: client session to change the state of. * @new_state: state to change to. * - * returns true if successful, false if the requested state can not be set. + * returns true if sess's state is changed to new state, otherwise return false. * * Locks: * state_wq lock must be hold. */ -static bool __rtrs_clt_change_state(struct rtrs_clt_sess *sess, +static bool rtrs_clt_change_state(struct rtrs_clt_sess *sess, enum rtrs_clt_state new_state) { enum rtrs_clt_state old_state; @@ -286,7 +286,7 @@ static bool rtrs_clt_change_state_from_to(struct rtrs_clt_sess *sess, spin_lock_irq(&sess->state_wq.lock); if (sess->state == old_state) - changed = __rtrs_clt_change_state(sess, new_state); + changed = rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; @@ -1361,7 +1361,7 @@ static bool rtrs_clt_change_state_get_old(struct rtrs_clt_sess *sess, spin_lock_irq(&sess->state_wq.lock); if (old_state) *old_state = sess->state; - changed = __rtrs_clt_change_state(sess, new_state); + changed = rtrs_clt_change_state(sess, new_state); spin_unlock_irq(&sess->state_wq.lock); return changed; From patchwork Thu Dec 17 14:19:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979861 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2268AC2BBD4 for ; Thu, 17 Dec 2020 14:20:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5D272395A for ; Thu, 17 Dec 2020 14:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728372AbgLQOUn (ORCPT ); Thu, 17 Dec 2020 09:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728338AbgLQOUn (ORCPT ); Thu, 17 Dec 2020 09:20:43 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EF7C0611CF for ; Thu, 17 Dec 2020 06:19:30 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id d17so38116979ejy.9 for ; Thu, 17 Dec 2020 06:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rWIBp61eWpeeSiM2PO3HAO/lWFN6/Kggc1TmjydEVeo=; b=GXrCYwsl/ebMrIiNgtWgA2YNVYDGjVnc8eNaOQDZn9qGloPs7a+6gtsZIZYbsZKbf2 H6d8BwpFIRlHOJa4dLDfdABUkB0huC8jo4CdX4oJqdeM3cxUecBr5fPO6FjdKMsPG3ND d3kS6E7R+xytWc58PKV8X3iz4l2xz0pWpCr9LlpbZOXcfu1Yaw04TwfZNTENWNOTFxYc IxlpEC9SDbGfn9JiePKWvYouTADsAu3QnmCw0oBBS8FEy0kTCX9mYXI+u1ouRLfXmWyw tNW5tATAsLHe0meK+c57OYDKjOSH8ZzK36zm4NMPDSOKcJanwtxdn1lSjELfFEQB9pVK 3d7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rWIBp61eWpeeSiM2PO3HAO/lWFN6/Kggc1TmjydEVeo=; b=I9dmmPKkVjJSh9jdn5wu0/z+egR69WevNPYxjt0dWILhB7UfnQyY3C8wIxF7HSsKlf a2dAImWhpy4Bn2cntcViJfNPksCu5vVS3Z3xxR+zyKzFE+QTJmtGXLxtw3JubtbwR6uj olXjb91vhbNFpPfYBRSNboukxO3yshCp4IK31u5fcHnW2CNWZp5MW7Re3CmNt4ynv0HJ S+n72QBDwh/pykjhLK53ynz+UnWbmjNAQCe4zmE6poj6/xWUmYOLduV37bIY31eYRrR2 CwNLPT0AN/I4eXcxg3xGAhsNRGQimWO6N1TJ6AJGc4/+XvzjZ2B1+TLyksR6vL8Cn8m2 FSEA== X-Gm-Message-State: AOAM531dAfmntyWLe0rh3CttkMWVtAI33gT83pUy1zT4WfVr5YiN2F82 SYdLLLuz3bRK/l15sL0FUM0EPPRVIjl8Aw== X-Google-Smtp-Source: ABdhPJyJETbT5kqrbW6Bg4/spbywqPs0TZU39duRdspDdkQivSDorFa79yRW6h3cZPT8ZDefaNwwjg== X-Received: by 2002:a17:906:924a:: with SMTP id c10mr35159031ejx.113.1608214768996; Thu, 17 Dec 2020 06:19:28 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:28 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Md Haris Iqbal , Guoqing Jiang Subject: [PATCHv2 for-next 13/19] RDMA/rtrs-srv: Fix missing wr_cqe Date: Thu, 17 Dec 2020 15:19:09 +0100 Message-Id: <20201217141915.56989-14-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We had a few places wr_cqe is not set, which could lead to NULL pointer deref or GPF in error case. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Reviewed-by: Md Haris Iqbal Signed-off-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 89e938a1a4fb..465f20d6b89c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -267,6 +267,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) WARN_ON_ONCE(rkey != wr->rkey); wr->wr.opcode = IB_WR_RDMA_WRITE; + wr->wr.wr_cqe = &io_comp_cqe; wr->wr.ex.imm_data = 0; wr->wr.send_flags = 0; @@ -294,6 +295,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) inv_wr.sg_list = NULL; inv_wr.num_sge = 0; inv_wr.opcode = IB_WR_SEND_WITH_INV; + inv_wr.wr_cqe = &io_comp_cqe; inv_wr.send_flags = 0; inv_wr.ex.invalidate_rkey = rkey; } @@ -304,6 +306,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id) srv_mr = &sess->mrs[id->msg_id]; rwr.wr.opcode = IB_WR_REG_MR; + rwr.wr.wr_cqe = &local_reg_cqe; rwr.wr.num_sge = 0; rwr.mr = srv_mr->mr; rwr.wr.send_flags = 0; @@ -379,6 +382,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, if (need_inval) { if (likely(sg_cnt)) { + inv_wr.wr_cqe = &io_comp_cqe; inv_wr.sg_list = NULL; inv_wr.num_sge = 0; inv_wr.opcode = IB_WR_SEND_WITH_INV; @@ -421,6 +425,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id, srv_mr = &sess->mrs[id->msg_id]; rwr.wr.next = &imm_wr; rwr.wr.opcode = IB_WR_REG_MR; + rwr.wr.wr_cqe = &local_reg_cqe; rwr.wr.num_sge = 0; rwr.wr.send_flags = 0; rwr.mr = srv_mr->mr; From patchwork Thu Dec 17 14:19:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979863 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04DC5C4361B for ; Thu, 17 Dec 2020 14:20:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8CE0238EF for ; Thu, 17 Dec 2020 14:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728356AbgLQOUn (ORCPT ); Thu, 17 Dec 2020 09:20:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728155AbgLQOUm (ORCPT ); Thu, 17 Dec 2020 09:20:42 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E35C0611D0 for ; Thu, 17 Dec 2020 06:19:31 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id qw4so38044682ejb.12 for ; Thu, 17 Dec 2020 06:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EDx0d7sqRwEf6BTXoENkSiqZnuiDyLvadt8JMtY/Ios=; b=XdMDmPcZRDJH7OX2Iw6FKrSs6Aq1WeNs0wZ7OohyRx0HJMAVmzEgK7nvHu3lU27MfA csvbOJtqDC9I1pvUzrz6NBttCsS1jbQHooDce4KmdFzyqVQYb2Sbby37i9kA4zSv4hcT z7Tdlk+5rqJ6klbgqd0EaFAMWXk/J1XLuO7/3ik7rAxXuOE9T1XncQ/TFztg1RIweKBn A+hwP1yghNOnnib4CwkTH9p6M0Z0IVUjoVAy0+CjUCEZ047YJ5a1x6V95eTbd/lHwUKP j+LHuIb7K5KuW/MxzI5YOkGE0dpsz03LkSwpIxbYypPoa/bo9XzcThiVeHzZl+5hrw4Z 18vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EDx0d7sqRwEf6BTXoENkSiqZnuiDyLvadt8JMtY/Ios=; b=lhZVzes7EDAouRR6DmV5dnK2UWP57jlgCp3s/xJh1/gveOa7ub7jzGdjWzGmAr1GdK hdOQc3aT+2xmeiykH+Wl1XA3lPdn6ExSGGNvm0QIPRSMoVbFefLw0xhM6dkzvM/ecjgu wN53ry7ZFglMl2G/vhDOdDaakUAgv41QaYxi5yMAc+9XMRsJ94uEcIDIyXaVmhZLM0HX VdPFtYqRcaXc/WjlRiNk2whxfmeOdhWOGqsu0lZwFT81vdXVzzFzWAoqoIJRQ2+E0Ckc YJuUtRM+dvppnn7AsBHr2RqyuAoUlpYd5dO8pPdT5KGekJ1FPCjciKThnpz8AKPKJQCd BNow== X-Gm-Message-State: AOAM532XXkLdheYKC/Jr07IpmEUU32ZoP8Z/u/iWVR0+UFWeF4JP1lmo WxRIi3p0ldgYc0SF6tBXrglaP6cWkdT3EA== X-Google-Smtp-Source: ABdhPJxYwIjI2VjAlGzYGT14HI4A5+Wd/IEc/k7afj6pdWIvQD7w9i6HUWmMyiREWiUOC8etDTfKrg== X-Received: by 2002:a17:906:71ca:: with SMTP id i10mr17695285ejk.528.1608214769982; Thu, 17 Dec 2020 06:19:29 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:29 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Guoqing Jiang , Md Haris Iqbal Subject: [PATCHv2 for-next 14/19] RDMA/rtrs-clt: Refactor the failure cases in alloc_clt Date: Thu, 17 Dec 2020 15:19:10 +0100 Message-Id: <20201217141915.56989-15-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang Make all failure cases go to the common path to avoid duplicate code. And some issued existed before. 1. clt need to be freed to avoid memory leak. 2. return ERR_PTR(-ENOMEM) if kobject_create_and_add fails, because rtrs_clt_open checks the return value of by call "IS_ERR(clt)". Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 3c90718f668d..493f45a33b5e 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2568,11 +2568,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, clt->dev.class = rtrs_clt_dev_class; clt->dev.release = rtrs_clt_dev_release; err = dev_set_name(&clt->dev, "%s", sessname); - if (err) { - free_percpu(clt->pcpu_path); - kfree(clt); - return ERR_PTR(err); - } + if (err) + goto err; /* * Suppress user space notification until * sysfs files are created @@ -2580,29 +2577,31 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, dev_set_uevent_suppress(&clt->dev, true); err = device_register(&clt->dev); if (err) { - free_percpu(clt->pcpu_path); put_device(&clt->dev); - return ERR_PTR(err); + goto err; } clt->kobj_paths = kobject_create_and_add("paths", &clt->dev.kobj); if (!clt->kobj_paths) { - free_percpu(clt->pcpu_path); - device_unregister(&clt->dev); - return NULL; + err = -ENOMEM; + goto err_dev; } err = rtrs_clt_create_sysfs_root_files(clt); if (err) { - free_percpu(clt->pcpu_path); kobject_del(clt->kobj_paths); kobject_put(clt->kobj_paths); - device_unregister(&clt->dev); - return ERR_PTR(err); + goto err_dev; } dev_set_uevent_suppress(&clt->dev, false); kobject_uevent(&clt->dev.kobj, KOBJ_ADD); return clt; +err_dev: + device_unregister(&clt->dev); +err: + free_percpu(clt->pcpu_path); + kfree(clt); + return ERR_PTR(err); } static void free_clt(struct rtrs_clt *clt) From patchwork Thu Dec 17 14:19:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979871 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3D8C4361B for ; Thu, 17 Dec 2020 14:21:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B7D12389F for ; Thu, 17 Dec 2020 14:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgLQOVI (ORCPT ); Thu, 17 Dec 2020 09:21:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728437AbgLQOVH (ORCPT ); Thu, 17 Dec 2020 09:21:07 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5701EC0611E4 for ; Thu, 17 Dec 2020 06:19:32 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id w1so33433321ejf.11 for ; Thu, 17 Dec 2020 06:19:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dC433w+l94tzlmYEUA1IqAKrp3WUB5gM49lo3vgomRs=; b=ddY9/tDTTIvt5H22X9KDu/FgD8IW2dccy6QVnsiRUw4y+gsJcgpW8mDibC1lnpwLkI osZbIAYTGRiNNjbnc2YzMW3P18drbFihm/1YmjriFhRIESHfYOltldpjWQ4ejeWiFF2s Uc/0oTr4nZ8W45j2eEefqhdywCimY+MVkbUSea1dBDPhdCVFe+9dFEL+nVA5FXW7ZF/H 69qaQ6Q4Hxhs/DKkNdbHS7VMXC1NqnDstF6gENjXOowULFZRtiQZyLTayMo8oU0LGNlH lwZSmoGDOl/x74s+L0nSWkJqGpLKd2FD3bDdJ4pM+nArsFtISo12/OZTMsHOFWFXFDFL l74g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dC433w+l94tzlmYEUA1IqAKrp3WUB5gM49lo3vgomRs=; b=PsPfjBboXx04XpiKURJl/r2lUVzvoPsAEQni95AA8IFc8a6Ie6hl03HPGVbfbBNNNZ L6gfhTFLcEeETkyARX+pS6qqLw0H4Kd9p9ndeVCwLkQVArM3E8Nw/S4gLoKTLqh/TbMs UYRaaNmLvP7NHhOY9N3kpufRKCMQofzgrpHdHTApzU++l8gFD7ZhC7qODNEl6SSeefjP YVBPEkGbMGqMgccIKmjEtzo7rRZIjXadhcdz+fA/tmNMhjtpqBTXnjips5q1ClKBy3v5 U34GOPZPyUCw8FlIW5NEFjotTVJc2pvUhqE0l9cVUUcAS4aQztHeaddF2kjMPPbf7vzy df8Q== X-Gm-Message-State: AOAM531JurYpAVdGVF8EWnNcNbszkLiWc6Av93f32uK/E8Sj0L9Rtiw4 ObD3nS7AGELeum+aS3908VFVHTcCCZl7vg== X-Google-Smtp-Source: ABdhPJxEUEWVB8lLvkaVM/SrDGdNBio8L5xF2DgmBZXQMNhc3zUkcx5BWQHX3MMgxNsldMQopwENLg== X-Received: by 2002:a17:906:8354:: with SMTP id b20mr35313410ejy.397.1608214770930; Thu, 17 Dec 2020 06:19:30 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:30 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 15/19] RDMA/rtrs: Do not signal for heatbeat Date: Thu, 17 Dec 2020 15:19:11 +0100 Message-Id: <20201217141915.56989-16-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org For HB, there is no need to generate signal for completion. Also remove a comment accordingly. Fixes: c0894b3ea69d ("RDMA/rtrs: core: lib functions shared between client and server modules") Signed-off-by: Jack Wang Reported-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 1 - drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 - drivers/infiniband/ulp/rtrs/rtrs.c | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 493f45a33b5e..2053bf99418a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -664,7 +664,6 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) case IB_WC_RDMA_WRITE: /* * post_send() RDMA write completions of IO reqs (read/write) - * and hb */ break; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 465f20d6b89c..8ea1df6b4da0 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1242,7 +1242,6 @@ static void rtrs_srv_rdma_done(struct ib_cq *cq, struct ib_wc *wc) case IB_WC_SEND: /* * post_send() RDMA write completions of IO reqs (read/write) - * and hb */ atomic_add(srv->queue_depth, &con->sq_wr_avail); diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index df52427f1710..97af8f0bb806 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -310,7 +310,7 @@ void rtrs_send_hb_ack(struct rtrs_sess *sess) imm = rtrs_to_imm(RTRS_HB_ACK_IMM, 0); err = rtrs_post_rdma_write_imm_empty(usr_con, sess->hb_cqe, imm, - IB_SEND_SIGNALED, NULL); + 0, NULL); if (err) { sess->hb_err_handler(usr_con); return; @@ -339,7 +339,7 @@ static void hb_work(struct work_struct *work) } imm = rtrs_to_imm(RTRS_HB_MSG_IMM, 0); err = rtrs_post_rdma_write_imm_empty(usr_con, sess->hb_cqe, imm, - IB_SEND_SIGNALED, NULL); + 0, NULL); if (err) { sess->hb_err_handler(usr_con); return; From patchwork Thu Dec 17 14:19:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979867 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AB70C4361B for ; Thu, 17 Dec 2020 14:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 168E1238EF for ; Thu, 17 Dec 2020 14:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726773AbgLQOUz (ORCPT ); Thu, 17 Dec 2020 09:20:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgLQOUz (ORCPT ); Thu, 17 Dec 2020 09:20:55 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B8AC0611BB for ; Thu, 17 Dec 2020 06:19:33 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id g20so38140022ejb.1 for ; Thu, 17 Dec 2020 06:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jVqdZVRi5hPWUiDXaKzaAVmLh/FfF7hda4xCmPJXXmA=; b=HPbVUVghXTZPm2B5Er3aPBYbe+qBmbusjeJm+HYAFtLuBa3YXin6KjdZoZpWZOnjLE b1lQoWAS9rabeAd/UEbWEN3PRn13odq1A4EkF0JxhhD1lAIyFkxGGSbcPuXVxFd86Qkc XU5xgeGd/Upobi8oF0MMmgny0YNM40IDTIbGTfrL1Od2MCbBGLtDdB8cRc5D6Ha2w5wf cc/mez6OfGK9GBjmG/Yp6p+BrQIr8XiKxh245XdM7p/Od1ajpQhJiBCtivPxcOuU1vT1 le9+bg5/kcifvJyZYRaU6Sk7sDs0rWVpPztz/g0HfesNuPeMVnl1YiFE5fnKGodro1r5 m15g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jVqdZVRi5hPWUiDXaKzaAVmLh/FfF7hda4xCmPJXXmA=; b=UaDAGV7l0opvdZ1SdRizfXmCjm/oOH9X5Ddr5iO9cW1/vVTkEUkGfPQ2ItZJvxfB8v 7dNLEaYLZuflM50/yiPpdtR8SrDpQjJkVd17t0K2c6dzM3kgIMEsCZPeEl12M84YsNSs dOulRdly1vHkYTCYamsZIyn0QMBwY8hctBg0Am0B1lP1EcP4mGJv+HfHyyO7d2bCjBVL uaTeu/l8XVI0jUpNMSL3Lg2G2G1EAhUW+kqC3GCUTmAHP/OsLG4RWqt1QstWV94ntpyO GzAkGQhs4pSSvcX+YgsTiVH73Hel57CCSnv2D4d64EvRQzrn0GPHN+dVbavcATF5dAjY HPNw== X-Gm-Message-State: AOAM533Grrim+qpd/B3k8vn56IzNlP4VywqHEm3w5ubnlTrXl+oX48Eu bAcrghpFy8flvurAj8l4I0i4jmipblAkVg== X-Google-Smtp-Source: ABdhPJyMPZ41tSL3VTpY6xdyl98fePpOq0DofRNbAAa1QukDkc+vnhVIiSbtqa/XjchqJrLZAEyKxg== X-Received: by 2002:a17:906:e15:: with SMTP id l21mr35659172eji.509.1608214771816; Thu, 17 Dec 2020 06:19:31 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:31 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 16/19] RDMA/rtrs-clt: Use bitmask to check sess->flags Date: Thu, 17 Dec 2020 15:19:12 +0100 Message-Id: <20201217141915.56989-17-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We may want to add new flags, so it's better to use bitmask to check flags. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 2053bf99418a..7644c3f627ca 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -494,7 +494,7 @@ static void rtrs_clt_recv_done(struct rtrs_clt_con *con, struct ib_wc *wc) int err; struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); - WARN_ON(sess->flags != RTRS_MSG_NEW_RKEY_F); + WARN_ON((sess->flags & RTRS_MSG_NEW_RKEY_F) == 0); iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); err = rtrs_iu_post_recv(&con->c, iu); @@ -514,7 +514,7 @@ static void rtrs_clt_rkey_rsp_done(struct rtrs_clt_con *con, struct ib_wc *wc) u32 buf_id; int err; - WARN_ON(sess->flags != RTRS_MSG_NEW_RKEY_F); + WARN_ON((sess->flags & RTRS_MSG_NEW_RKEY_F) == 0); iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); @@ -621,12 +621,12 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) } else if (imm_type == RTRS_HB_MSG_IMM) { WARN_ON(con->c.cid); rtrs_send_hb_ack(&sess->s); - if (sess->flags == RTRS_MSG_NEW_RKEY_F) + if (sess->flags & RTRS_MSG_NEW_RKEY_F) return rtrs_clt_recv_done(con, wc); } else if (imm_type == RTRS_HB_ACK_IMM) { WARN_ON(con->c.cid); sess->s.hb_missed_cnt = 0; - if (sess->flags == RTRS_MSG_NEW_RKEY_F) + if (sess->flags & RTRS_MSG_NEW_RKEY_F) return rtrs_clt_recv_done(con, wc); } else { rtrs_wrn(con->c.sess, "Unknown IMM type %u\n", @@ -654,7 +654,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) WARN_ON(!(wc->wc_flags & IB_WC_WITH_INVALIDATE || wc->wc_flags & IB_WC_WITH_IMM)); WARN_ON(wc->wr_cqe->done != rtrs_clt_rdma_done); - if (sess->flags == RTRS_MSG_NEW_RKEY_F) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F) { if (wc->wc_flags & IB_WC_WITH_INVALIDATE) return rtrs_clt_recv_done(con, wc); @@ -679,7 +679,7 @@ static int post_recv_io(struct rtrs_clt_con *con, size_t q_size) struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess); for (i = 0; i < q_size; i++) { - if (sess->flags == RTRS_MSG_NEW_RKEY_F) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F) { struct rtrs_iu *iu = &con->rsp_ius[i]; err = rtrs_iu_post_recv(&con->c, iu); @@ -1563,7 +1563,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) sess->queue_depth * 3 + 1); } /* alloc iu to recv new rkey reply when server reports flags set */ - if (sess->flags == RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { + if (sess->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) { con->rsp_ius = rtrs_iu_alloc(max_recv_wr, sizeof(*rsp), GFP_KERNEL, sess->s.dev->ib_dev, DMA_FROM_DEVICE, From patchwork Thu Dec 17 14:19:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979873 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E95CC2BB48 for ; Thu, 17 Dec 2020 14:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEAD02395A for ; Thu, 17 Dec 2020 14:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728558AbgLQOVV (ORCPT ); Thu, 17 Dec 2020 09:21:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726999AbgLQOVU (ORCPT ); Thu, 17 Dec 2020 09:21:20 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FA0C0619D2 for ; Thu, 17 Dec 2020 06:19:34 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id jx16so38093307ejb.10 for ; Thu, 17 Dec 2020 06:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vEuWFoKytWABvotO7nLGCLUvqS5FiiKvtoEn79wZVmk=; b=DbFrQGZSOGMGfBwbZfju0J94RHvzZOh//q6gcqaP9AiLTzeWRBXRosPb/9KVb41HHi rrC9lwN0Xa9urSqtpE3mQduNF7SfXOBSpe6wgscOw23m0XnslrUoDbLaOShd6IedQ1bm h/eulvy3B9WGcRZGLJGOlc5XADNCwKtiwWyAXZ8/4XAHuqTbO1qMd7Y2hirhhhClg+Sj noq4TDE4eX3tWfdnl6TlAbLVDgj9AxvpYG8C1z+APyI97OT6z57EXREue+eoNsnFq3mB 6f9Ofl6CdhqfhD2vP1c1zcrZLFvXW+drvGmrhUhZh7k7cm0hvdp65lE8wLIgCqxA1aqb e3wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vEuWFoKytWABvotO7nLGCLUvqS5FiiKvtoEn79wZVmk=; b=hZwdZfCllMygUHASdL8fIJUxBvXytnDpJm66DllRbR3bHrO+vW5/dfLUh1bPTxhx9u fubikZ9th80xwO0F/vA6ZklGPBSiAfwEBNZg21jVfYeSV4xJTdWzkF+QmF9dy6gNS9Zd 58P73CsJWFejGH7L+pKjgFrUhJdG+Etom3euUFlUtNJ59Be4zCyx/G57PlKvYM/E8Fya 6vVNfv1YYbacrFjbn8OIMPqgCjCmSS4YptjG8pmLDzWHhxXA935wFS8AS7ThKk9lEV5j +2MrQXMRsn1LjgLjz8coSSttgNR4Viq+8p1HO7w4FNpmZ5hxlO/8p91rypvxMc1Z6Ts9 Cu5A== X-Gm-Message-State: AOAM5301I8W2b9fn/j1mVVwHf2LTSfb1QpZYQCZsGGtzUmgx8wdbrHnk wpvpUPMeEIEDiCmdYZ6t9rEQKAYB97x7aw== X-Google-Smtp-Source: ABdhPJwMbzNvdmTaB1jM/ErKDbmhnM9S1wNd5vHKAfUDD7zo39BJgP1n0F5waawpavmab5sFiQeS+w== X-Received: by 2002:a17:906:4756:: with SMTP id j22mr36383724ejs.353.1608214772875; Thu, 17 Dec 2020 06:19:32 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:32 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 17/19] RDMA/rtrs-srv: Do not signal REG_MR Date: Thu, 17 Dec 2020 15:19:13 +0100 Message-Id: <20201217141915.56989-18-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We do not need to wait for REG_MR completion, so remove the SIGNAL flag. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 8ea1df6b4da0..2798c655d7ae 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -818,7 +818,7 @@ static int process_info_req(struct rtrs_srv_con *con, rwr[mri].wr.opcode = IB_WR_REG_MR; rwr[mri].wr.wr_cqe = &local_reg_cqe; rwr[mri].wr.num_sge = 0; - rwr[mri].wr.send_flags = mri ? 0 : IB_SEND_SIGNALED; + rwr[mri].wr.send_flags = 0; rwr[mri].mr = mr; rwr[mri].key = mr->rkey; rwr[mri].access = (IB_ACCESS_LOCAL_WRITE | From patchwork Thu Dec 17 14:19:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979869 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B02BCC2BB9A for ; Thu, 17 Dec 2020 14:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8477B238EF for ; Thu, 17 Dec 2020 14:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728063AbgLQOU4 (ORCPT ); Thu, 17 Dec 2020 09:20:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbgLQOUz (ORCPT ); Thu, 17 Dec 2020 09:20:55 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248F9C0619D4 for ; Thu, 17 Dec 2020 06:19:35 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id qw4so38045004ejb.12 for ; Thu, 17 Dec 2020 06:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0l8ELeizMdgasVxuWqcV1kW9L+4uQLAYqusCbE9QO7o=; b=YwB02qLoBEnkzdd2E70f4Vsh+nQpEIsL/JJvQFHQTyCXmP1vTLpAr9c+8B8ACIHH2O aFi3sHuuPiRGoA90em0G8yIIRayvR8u7TAcGXqxL7ojk/0pXro+Y6NkH1UpE+Z0KGWdF nvLtcqFW8FIbW3iN7u46IWEM7DCIk7BhjdHx+m84LXuRSBV9HcDc5cNUzxtTWQDeze3b xHFVZgVG8STuBJnZRJVR36BXwhxIwldx1W8/4ua9u+/I1dNzlJhjzjqKfzoN+eTN/86X 7BxhUES72k5m21v8XuivCdFlDM5CIhMSacE/CKut0IDHRvGvVCPM2b5X8LtHUaVmz23T ENOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0l8ELeizMdgasVxuWqcV1kW9L+4uQLAYqusCbE9QO7o=; b=rz50OqdmHouLBNseDpT1h4FWRYwXPe+j4R9JBvVt34zG/CPT2Yi4zCAUfyFBXav9T5 ZU4U5CGCn/EgDp1on2nI0MjvfHAhaA1pZV/iNw1ftHajQkLatiircn1bOgO8mhLlbR2K hr0iCNzcF6gS8j5fRrRin55HewF8W86Dn6rPcOMmoN/Won5BBgvM84KFQVVcHEEZkrRA Jo0fNC3WMHhH5pLVMWh7LNnIgwH6n4LByvbc8Ytmf5m5wPEGeCdY9GZQ2MjZiZQ/WghW rYIIcixzu83ZErx7TG4gBHfcTqO4AQpMoTx/YZyknt62lLVxErkYesES1+kXCbIrdTs6 Mazg== X-Gm-Message-State: AOAM532oH9TmETUSndsbFHW2Mo1TaBBxNGX0PNi1O7BW44m1DjZqKJy6 B0tyydVaSAa2XDnEqCGxw8PY/1ZGxB+0qA== X-Google-Smtp-Source: ABdhPJxzfgb7xvivWbvTYP1BHPIR1o+xuQ6V3krCtBNACLSA58IR4qQtnIuFVXzAj976sXtCFv0czQ== X-Received: by 2002:a17:906:aac1:: with SMTP id kt1mr19942406ejb.329.1608214773786; Thu, 17 Dec 2020 06:19:33 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:33 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 18/19] RDMA/rtrs-srv: Init wr_cnt as 1 Date: Thu, 17 Dec 2020 15:19:14 +0100 Message-Id: <20201217141915.56989-19-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Fix up wr_avail accounting. if wr_cnt is 0, then we do SIGNAL for first wr, in completion we add queue_depth back, which is not right in the sense of tracking for available wr. So fix it by init wr_cnt to 1. Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality") Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 2798c655d7ae..54abbd9562d0 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1603,7 +1603,7 @@ static int create_con(struct rtrs_srv_sess *sess, con->c.cm_id = cm_id; con->c.sess = &sess->s; con->c.cid = cid; - atomic_set(&con->wr_cnt, 0); + atomic_set(&con->wr_cnt, 1); if (con->c.cid == 0) { /* From patchwork Thu Dec 17 14:19:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 11979875 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B08C2BBCA for ; Thu, 17 Dec 2020 14:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E41C02389F for ; Thu, 17 Dec 2020 14:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgLQOVW (ORCPT ); Thu, 17 Dec 2020 09:21:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727385AbgLQOVU (ORCPT ); Thu, 17 Dec 2020 09:21:20 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11B3EC0619D5 for ; Thu, 17 Dec 2020 06:19:36 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id b9so13165962ejy.0 for ; Thu, 17 Dec 2020 06:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZRNr7nlUEozad4LnhtqJsV5xxVNxa/4zZv9vQgfZxek=; b=EOm1E3k/fHhRNp6AmbQfjcTLEZjkikBV4iCKGSHdMSCEmZk0Hwk0Sauwe/6YziDTLD e4yWjVqCR/vSTv9+QohZmARiUqIiYPp1QE0fCyxI0279hmAdjOuEtkrBnrkW/EoeT13B 4wvnfGYOeB/7BTnCn8SHOMn+u7Lvj194O5dwJldyP+Y0J3LtbDV6cR+iPKChKD7l4GW/ bOHplG2S1tre3irTiek64o7icd70k+L0iA/5k7VFHDpNM+zCT0A9pdl0TSn7uObTE0Lq dpoYH5KQaiGcbwMTt1D3pUR27QG/ymJGYMux5C8kYXfn6KYe836tJRLQRaYtxpKT9UfY FuZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZRNr7nlUEozad4LnhtqJsV5xxVNxa/4zZv9vQgfZxek=; b=sZCNwEjFP3l0Vc6aYwTgPGQ2gO6u1HDSMjygYkHzEA2FwIovoWDgWpOEXUng/XN2xh XN0C7LJxwitq0c76o2JnUYS/hlLMQl3k03vqfO9GzxrPj5oVc4h24JAadBX+su18DYvo xlZ081OgIYuz3amgO4LWAeq5y7libVuCwDZFI3Nuku/A08EY5067B9WMU6yoBX4W+NsC EnClUDKNuP6BjRVFko1kzrI+TRTwpXCt8Igdmh3J9uDMARk7UyM+jkJYvyfYWmCY39Rk NC4XkZXOjZGjANul3o8foIPRalkAHZT3hearsRzCuRM55RgWf2/G5ZmPNV6z6E1S5xoq QkOw== X-Gm-Message-State: AOAM530f2MV2o9Dq74UfB834SPDO8h7+bdc26wIAtNMMkxy9DUGnD/1R qC+bTu2vjt0mN/vq8IiZBOgW53eq/dHmBQ== X-Google-Smtp-Source: ABdhPJwZj+XkgOmjP99XGOotuLKcuC/eiA1tyRtRVKmFSknI/W54fgGPNeO7HkC6adXZQ6KU7aeMHQ== X-Received: by 2002:a17:906:7104:: with SMTP id x4mr36161709ejj.141.1608214774600; Thu, 17 Dec 2020 06:19:34 -0800 (PST) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:4991:de00:e5a4:2f4d:99:ddc5]) by smtp.gmail.com with ESMTPSA id b14sm18168969edu.3.2020.12.17.06.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 06:19:34 -0800 (PST) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com, Gioh Kim Subject: [PATCHv2 for-next 19/19] RDMA/rtrs: Fix KASAN: stack-out-of-bounds bug Date: Thu, 17 Dec 2020 15:19:15 +0100 Message-Id: <20201217141915.56989-20-jinpu.wang@cloud.ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> References: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org When KASAN is enabled, we notice warning below: [ 483.436975] ================================================================== [ 483.437234] BUG: KASAN: stack-out-of-bounds in _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.437430] Read of size 4 at addr ffff88a195fd7d30 by task kworker/1:3/6954 [ 483.437731] CPU: 1 PID: 6954 Comm: kworker/1:3 Kdump: loaded Tainted: G O 5.4.82-pserver #5.4.82-1+feature+linux+5.4.y+dbg+20201210.1532+987e7a6~deb10 [ 483.437976] Hardware name: Supermicro Super Server/X11DDW-L, BIOS 3.3 02/21/2020 [ 483.438168] Workqueue: rtrs_server_wq hb_work [rtrs_core] [ 483.438323] Call Trace: [ 483.438486] dump_stack+0x96/0xe0 [ 483.438646] ? _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.438802] print_address_description.constprop.6+0x1b/0x220 [ 483.438966] ? _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.439133] ? _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.439285] __kasan_report.cold.9+0x1a/0x32 [ 483.439444] ? _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.439597] kasan_report+0x10/0x20 [ 483.439752] _mlx5_ib_post_send+0x188a/0x2560 [mlx5_ib] [ 483.439910] ? update_sd_lb_stats+0xfb1/0xfc0 [ 483.440073] ? set_reg_wr+0x520/0x520 [mlx5_ib] [ 483.440222] ? update_group_capacity+0x340/0x340 [ 483.440377] ? find_busiest_group+0x314/0x870 [ 483.440526] ? update_sd_lb_stats+0xfc0/0xfc0 [ 483.440683] ? __bitmap_and+0x6f/0x100 [ 483.440832] ? __lock_acquire+0xa2/0x2150 [ 483.440979] ? __lock_acquire+0xa2/0x2150 [ 483.441128] ? __lock_acquire+0xa2/0x2150 [ 483.441279] ? debug_lockdep_rcu_enabled+0x23/0x60 [ 483.441430] ? lock_downgrade+0x390/0x390 [ 483.441582] ? __lock_acquire+0xa2/0x2150 [ 483.441729] ? __lock_acquire+0xa2/0x2150 [ 483.441876] ? newidle_balance+0x425/0x8f0 [ 483.442024] ? __lock_acquire+0xa2/0x2150 [ 483.442172] ? debug_lockdep_rcu_enabled+0x23/0x60 [ 483.442330] hb_work+0x15d/0x1d0 [rtrs_core] [ 483.442479] ? schedule_hb+0x50/0x50 [rtrs_core] [ 483.442627] ? lock_downgrade+0x390/0x390 [ 483.442781] ? process_one_work+0x40d/0xa50 [ 483.442931] process_one_work+0x4ee/0xa50 [ 483.443082] ? pwq_dec_nr_in_flight+0x110/0x110 [ 483.443231] ? do_raw_spin_lock+0x119/0x1d0 [ 483.443383] worker_thread+0x65/0x5c0 [ 483.443532] ? process_one_work+0xa50/0xa50 [ 483.451839] kthread+0x1e2/0x200 [ 483.451983] ? kthread_create_on_node+0xc0/0xc0 [ 483.452139] ret_from_fork+0x3a/0x50 The problem is we use wrong type when send wr, hw driver expect the type of IB_WR_RDMA_WRITE_WITH_IMM wr should be ib_rdma_wr, and doing container_of to access member. The fix is simple use ib_rdma_wr instread of ib_send_wr. Fixes: c0894b3ea69d ("RDMA/rtrs: core: lib functions shared between client and server modules") Signed-off-by: Jack Wang Reviewed-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 97af8f0bb806..d13aff0aa816 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -182,16 +182,16 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe, u32 imm_data, enum ib_send_flags flags, struct ib_send_wr *head) { - struct ib_send_wr wr; + struct ib_rdma_wr wr; - wr = (struct ib_send_wr) { - .wr_cqe = cqe, - .send_flags = flags, - .opcode = IB_WR_RDMA_WRITE_WITH_IMM, - .ex.imm_data = cpu_to_be32(imm_data), + wr = (struct ib_rdma_wr) { + .wr.wr_cqe = cqe, + .wr.send_flags = flags, + .wr.opcode = IB_WR_RDMA_WRITE_WITH_IMM, + .wr.ex.imm_data = cpu_to_be32(imm_data), }; - return rtrs_post_send(con->qp, head, &wr); + return rtrs_post_send(con->qp, head, &wr.wr); } EXPORT_SYMBOL_GPL(rtrs_post_rdma_write_imm_empty);