From patchwork Fri May 28 11:29:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286753 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 8CD64C4708D for ; Fri, 28 May 2021 11:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BD6861378 for ; Fri, 28 May 2021 11:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234246AbhE1LcF (ORCPT ); Fri, 28 May 2021 07:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbhE1LcD (ORCPT ); Fri, 28 May 2021 07:32:03 -0400 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 25BDAC061760 for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id j9so4464069edt.6 for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TYLHgeQhszM+/bQ2SSL6k+onPJ3gWhitmIrOhi+s9K8=; b=jNTsuYURtKJSgPRUkYLxdqT0n6nJqG2KkYAjm+lsQ1Ka2vyN3u1JbSSHjFRVGuJ5Ck eFgT1b+0X7dgM1jcx+0Tz4fu/qeMMVfkO2DCuMx/LeInxtY4jnZQ4uDulYAa8mV26Wqr TC/TfhQCbgAXmVclGmen/+zGNxbH1GDjbMg5RNpDM8hph1I4zxyPuoHmbth+H2dLzJuk xRH1ysRl0Di+fNdT8/lX5pWlu9zNOP09S2ISOJW+OACGlNssFR3yszGGS9D9RsNMVT1w LgA2SSQwXH96U/cINob5OqNfffR25gUArIvVTFR1BLPyTvPRmppObdqf1smSe1o+nfT4 PVtA== 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=TYLHgeQhszM+/bQ2SSL6k+onPJ3gWhitmIrOhi+s9K8=; b=V1+ExaVd267vxELbx0dbRtqzMjU8Dsw5Z4KEzACjjtGzAAsvM9seQwl+ADoXNPh1/1 g/XIcmk+x/HakTSQzYrL3j2cjzHv65mZ+JNquMJ/yOtVGDCyVX23LG008RQ2gKD62U+8 G1W0jWwzUhEcqIWpXyf+RGOxGi5jDx9ZfqaOs3SiWB6lqsOvr8mHgw1irTX+bdm0L1zN INHPtN33F/4G5B+a7CC9OFERz5OWU2kzf8Po/a32SOydOxFXL0EMxUaUtEM2OTUa0c16 M7Ht3wthcRNcN4Enne1Bd2OIV5mY6EjFOatpYwHMRWumDhDJrOCV39eGl60fCeuoEIjp R6cA== X-Gm-Message-State: AOAM533rpgXmIjHNwmSnhVH9fG0RFuLHxkHZ/EPIa+t36r/kWiUb9AGS oRstytlXKN1Vc/jI7lPeoregOV57bNWYEw== X-Google-Smtp-Source: ABdhPJzIr8UyoQLr8EvbsGa0KLNg3jTfr8svu4K9uHFaCaHbKQlIvF9oFkygvJDdrLr6A2QP4Hnyew== X-Received: by 2002:a05:6402:684:: with SMTP id f4mr9622036edy.25.1622201420639; Fri, 28 May 2021 04:30:20 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:20 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 01/20] RDMA/rtrs-srv: Kill reject_w_econnreset label Date: Fri, 28 May 2021 13:29:59 +0200 Message-Id: <20210528113018.52290-2-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang We can goto reject_w_err label after initialize err with -ECONNRESET. Reviewed-by: Md Haris Iqbal Signed-off-by: Guoqing Jiang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 0fa116cabc44..cf3283acc8e8 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1780,33 +1780,33 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, u16 version, con_num, cid; u16 recon_cnt; - int err; + int err = -ECONNRESET; if (len < sizeof(*msg)) { pr_err("Invalid RTRS connection request\n"); - goto reject_w_econnreset; + goto reject_w_err; } if (le16_to_cpu(msg->magic) != RTRS_MAGIC) { pr_err("Invalid RTRS magic\n"); - goto reject_w_econnreset; + goto reject_w_err; } version = le16_to_cpu(msg->version); if (version >> 8 != RTRS_PROTO_VER_MAJOR) { pr_err("Unsupported major RTRS version: %d, expected %d\n", version >> 8, RTRS_PROTO_VER_MAJOR); - goto reject_w_econnreset; + goto reject_w_err; } con_num = le16_to_cpu(msg->cid_num); if (con_num > 4096) { /* Sanity check */ pr_err("Too many connections requested: %d\n", con_num); - goto reject_w_econnreset; + goto reject_w_err; } cid = le16_to_cpu(msg->cid); if (cid >= con_num) { /* Sanity check */ pr_err("Incorrect cid: %d >= %d\n", cid, con_num); - goto reject_w_econnreset; + goto reject_w_err; } recon_cnt = le16_to_cpu(msg->recon_cnt); srv = get_or_create_srv(ctx, &msg->paths_uuid, msg->first_conn); @@ -1826,7 +1826,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, rtrs_err(s, "Session in wrong state: %s\n", rtrs_srv_state_str(sess->state)); mutex_unlock(&srv->paths_mutex); - goto reject_w_econnreset; + goto reject_w_err; } /* * Sanity checks @@ -1835,13 +1835,13 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, rtrs_err(s, "Incorrect request: %d, %d\n", cid, con_num); mutex_unlock(&srv->paths_mutex); - goto reject_w_econnreset; + goto reject_w_err; } if (s->con[cid]) { rtrs_err(s, "Connection already exists: %d\n", cid); mutex_unlock(&srv->paths_mutex); - goto reject_w_econnreset; + goto reject_w_err; } } else { sess = __alloc_sess(srv, cm_id, con_num, recon_cnt, @@ -1882,9 +1882,6 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, reject_w_err: return rtrs_rdma_do_reject(cm_id, err); -reject_w_econnreset: - return rtrs_rdma_do_reject(cm_id, -ECONNRESET); - close_and_return_err: mutex_unlock(&srv->paths_mutex); close_sess(sess); From patchwork Fri May 28 11:30:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286755 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 8243AC4708E for ; Fri, 28 May 2021 11:30:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 593F161378 for ; Fri, 28 May 2021 11:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233783AbhE1LcF (ORCPT ); Fri, 28 May 2021 07:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233734AbhE1LcD (ORCPT ); Fri, 28 May 2021 07:32:03 -0400 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 1A732C06174A for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b17so4535651ede.0 for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7oViSJszh4ibc5NUk8IoIqQ2ThRs5jfT+cX9V/c4t34=; b=V5WhwHvtpnnUV8C6DajZ8E4F/fSStdjGvae8w9rlUO0YUS1A90qcy5MY+aFphD6pGj hDsjeY7EGs/4kEaMWDJ/0hdK0XrIEd/qEXlepDIAiA2tAMC76UnMuQE0ATDtizNYFT8F MHxOlzKfCvyUiUtRCBJlyVlr5jJZBiIcZgtoB2hIQQ3uJGtcmujO6a8rxTnWSCc3PDuZ l2P3DgT7MESqR+6ScQaDtx2QDfMce/KpmHrXEdi6hYYSzBclSrO4T6TFXJQBcr7ptG/s gP2JBdUQWqg6uO8SBbvb67b2QD+fWO9b5hMPk5UV6ReWmrSBwQsL+2DKvJUT10KzBCZc n5hQ== 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=7oViSJszh4ibc5NUk8IoIqQ2ThRs5jfT+cX9V/c4t34=; b=YmIWUOntfOnxjYTzQ/FyM4F0k6N31xirkjhL0dWRxlpWkbXfQN8K2pFht1uGcRzGpd lUakxvsYG87DaC3m4qsLv/siLa86xuPQo1byF9zaq+ZgnoemK1BuO1vI8MB1Mrlx+RKy 1Nv+cVCT6t11JGvWNw3qXYFVZDQzWfFdWcYRlL/plZul8AggBfADZwLwDLz99bvwis9X L48Xcut6WOBJSJo186MX2yt02jcHOxGI1JlLzJJZ9TpCujp3PdI0HP/n8F7wS8azvHGf s1JXy3UtQm5ipZ4gxF7yx/+g/wI+o5UXgLHhUujdCoEi02aIGiyCnGWotqO5RNa4Cjfz BAzw== X-Gm-Message-State: AOAM533bEfppI5S6aBShyS77F6oY/sNpfoREtluPtpLs7jr2c4UXL1SW lIMsvYTt5OI3GotUjIdNEZBQydNmWN2Eqw== X-Google-Smtp-Source: ABdhPJw5Zqiyxi0V34ZvUjAuyLGrEu4QnU0AL6O6qIzT6vXc/0qoL4mIsnQU18t8wAFb5pFAvQxM/g== X-Received: by 2002:a05:6402:2691:: with SMTP id w17mr9643914edd.140.1622201421523; Fri, 28 May 2021 04:30:21 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:21 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 02/20] RDMA/rtrs-clt: Remove MAX_SESS_QUEUE_DEPTH from rtrs_send_sess_info Date: Fri, 28 May 2021 13:30:00 +0200 Message-Id: <20210528113018.52290-3-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim Client receives queue_depth value from server. There is no need to use MAX_SESS_QUEUE_DEPTH value. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 0a794d748a7a..97fa9da4dde4 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2465,7 +2465,7 @@ static int rtrs_send_sess_info(struct rtrs_clt_sess *sess) int err; rx_sz = sizeof(struct rtrs_msg_info_rsp); - rx_sz += sizeof(u64) * MAX_SESS_QUEUE_DEPTH; + rx_sz += sizeof(struct rtrs_sg_desc) * sess->queue_depth; tx_iu = rtrs_iu_alloc(1, sizeof(struct rtrs_msg_info_req), GFP_KERNEL, sess->s.dev->ib_dev, DMA_TO_DEVICE, From patchwork Fri May 28 11:30:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286759 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 13ECFC47090 for ; Fri, 28 May 2021 11:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E23DD61378 for ; Fri, 28 May 2021 11:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbhE1LcH (ORCPT ); Fri, 28 May 2021 07:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbhE1LcD (ORCPT ); Fri, 28 May 2021 07:32:03 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D892EC061761 for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id r11so4426949edt.13 for ; Fri, 28 May 2021 04:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jkNdeh8nbDctZK6SGkgOCmm67mVJfJlazEs9SPAqMzg=; b=H5u3zelF+uixWBKn2JhIyvVpOMLbphHyUSSmskAkMEZ062facrkTmB/NqM5cEi/vzW WJDVNtdcM29pviaxm256JKQI4uJAkIHZ5ZAOm8hhFOjqq4SNPMOjbsNb0A+wBuKrEkm+ 2C1wGcUK1gPyUyEA6aXA18+cItaAKe8Pc4rfwmnTO7pCJLTgtteIMigwxAF/qGTqUIhQ ZNzAEcKuVJIgn7VjjdhDlOk/aEVk1Hqajy16edMqw3aPLCwI+Bvra0E3F4k2awFeI69n 5szZflGllUCds4dqxPAYWHm6Oo3e8B/mtG86foDKXI4330ANXZWFbkgOfyCk78aYvvdO y1wA== 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=jkNdeh8nbDctZK6SGkgOCmm67mVJfJlazEs9SPAqMzg=; b=OAxGMD7C7EvXxh39bo4HwVSkU9NIOpFuVoIM2GEw41PcppFHn+LcDnnqtmKT5hUoJn 7qG0VlPMFBwmQSSLV8/Tau9DVri0zwelhPDy6Tzd2mj6cRmK/nea9yjjQHkqJvI6nMRP NbHbcPvyQyKYugSv9nxegk0qp+qPuWwV/nWhzqGGPOF4h4Ak17BBV/IOOZXyZ3fHHnsm V6KlfEEjeV9F/arMQMg5vv2aFbxyy12iFC1ZbLTc7+wTjTyk5Dz6WtweZiTfpp47At9D 9wyFA/FVDXfFwtctQlUEQr8K2+BXwlHi1mFxGXwzk369fQ8RsGxRz8tZzwFB7FjFVAWf yQjQ== X-Gm-Message-State: AOAM530+tLy0THHPd9CJ5RJmCDuhMpfNsHPJe++/BscfcGIz6oJjLI82 VMhMw+JMzMVMSs0KlnFmHGP9FqWZhq2JVQ== X-Google-Smtp-Source: ABdhPJxvA0ciaQRSfw/R7YKoTD2PXmEYJR+thd9F/093cDJFvKM+KeUwxP0BZmiTfa7B9ZvnzVMbqA== X-Received: by 2002:aa7:dd10:: with SMTP id i16mr9289500edv.274.1622201422310; Fri, 28 May 2021 04:30:22 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:22 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Gioh Kim Subject: [PATCHv3 for-next 03/20] RDMA/rtrs-srv: Add error messages for cases when failing RDMA connection Date: Fri, 28 May 2021 13:30:01 +0200 Message-Id: <20210528113018.52290-4-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Md Haris Iqbal It was difficult to find out why it failed to establish RDMA connection. This patch adds some messages to show which function has failed why. Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index cf3283acc8e8..7a0954aa24c8 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1356,8 +1356,10 @@ static struct rtrs_srv *get_or_create_srv(struct rtrs_srv_ctx *ctx, * If this request is not the first connection request from the * client for this session then fail and return error. */ - if (!first_conn) + if (!first_conn) { + pr_err_ratelimited("Error: Not the first connection request for this session\n"); return ERR_PTR(-ENXIO); + } /* need to allocate a new srv */ srv = kzalloc(sizeof(*srv), GFP_KERNEL); @@ -1812,6 +1814,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, srv = get_or_create_srv(ctx, &msg->paths_uuid, msg->first_conn); if (IS_ERR(srv)) { err = PTR_ERR(srv); + pr_err("get_or_create_srv(), error %d\n", err); goto reject_w_err; } mutex_lock(&srv->paths_mutex); @@ -1850,11 +1853,13 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, mutex_unlock(&srv->paths_mutex); put_srv(srv); err = PTR_ERR(sess); + pr_err("RTRS server session allocation failed: %d\n", err); goto reject_w_err; } } err = create_con(sess, cm_id, cid); if (err) { + rtrs_err((&sess->s), "create_con(), error %d\n", err); (void)rtrs_rdma_do_reject(cm_id, err); /* * Since session has other connections we follow normal way @@ -1865,6 +1870,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, } err = rtrs_rdma_do_accept(sess, cm_id); if (err) { + rtrs_err((&sess->s), "rtrs_rdma_do_accept(), error %d\n", err); (void)rtrs_rdma_do_reject(cm_id, err); /* * Since current connection was successfully added to the From patchwork Fri May 28 11:30:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286757 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 091A1C4708F for ; Fri, 28 May 2021 11:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D35FA613DA for ; Fri, 28 May 2021 11:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbhE1LcG (ORCPT ); Fri, 28 May 2021 07:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233841AbhE1LcD (ORCPT ); Fri, 28 May 2021 07:32:03 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F82C061763 for ; Fri, 28 May 2021 04:30:24 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id t3so4456126edc.7 for ; Fri, 28 May 2021 04:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UqI8oT48GQU5Cb3cgdbS9uhiAtyr8X1676tU5j3rscY=; b=XtLfibf9rI0H6odRlVHQBJi3CL04cBJuyl+Ff5mBYSW2vVqM4+s/R8rYbZ/CPkPCEK J0fPxUTeoP56K62yJmFJi1Jn0Dx/1M0ZuFWsp1AnaAtRgW1w2e/X5rNKH6+qjcjHENs0 FkmQhFJxRnY7Mgx+htPs6ndwfINYWjFVK903+MCMpFKukUELxmFkQ/OdgwcvBaqBe+NY K845Qs9eQhymoTpYEio11UDl5v41WD0OfOZNnVOGaCE97HLgeLxzYZwHtgXb4eatabKT C5+qV1zrDKh7+N2FYttK/FeP+bkq6RufkjHP/HiqszIxgwTAVzmCyzBd9OGl5i/Ewb8E MLOw== 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=UqI8oT48GQU5Cb3cgdbS9uhiAtyr8X1676tU5j3rscY=; b=lbVALeUr7wXJTARGT62nz8tbdIQIQE1qQ50XEVk/3j5yUP2cbAXLm99G6ie6Cj6wmX L3Q10Je4S/dYR4S2WfrbDRXG3Q+IPu0tqLmlsMHCCiIWFfXwIWD3aKtmPHrTKPk7lYcj rPz56rNIlEIAmiJTkxItCWekqpp4ZcV3loRWtsA3pAMdgOQluQTpmEi7S+8xXltuZwRC lPXutIQq0VgulfdSm49zk64OIS1ojAZIzUcMAdRf8WEbL758/Z4ZW6sszhcJ5KvYmJqa eawORB/s6Zil+9svLP96r4SckWK+gcGDyyv1YbaVSAK6ciZG6mBoKFAe1H2f7F1hN3Fg pvkw== X-Gm-Message-State: AOAM533Qgs76Cx6YW7ty0OYV48lHBVwXnO9kvCnTonFgli/HRECmfkjJ nuHCKUOgfqbkOEW769Q9Zer9oo8wmWuSCA== X-Google-Smtp-Source: ABdhPJwP1BE3j+Q1zEusu2ARcesZeJtw1zi2Bp/iYYdM3ETRHYjjYiM2RUzoTjPw8CITpf9YzkCWuw== X-Received: by 2002:a05:6402:3587:: with SMTP id y7mr9158523edc.360.1622201423112; Fri, 28 May 2021 04:30:23 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:22 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 04/20] RDMA/rtrs-srv: Clean up the code in __rtrs_srv_change_state Date: Fri, 28 May 2021 13:30:02 +0200 Message-Id: <20210528113018.52290-5-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang No need to use double switch to check the change of state everywhere, let's change them to "if" to reduce size. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 7a0954aa24c8..aa0585c176c9 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -77,32 +77,17 @@ static bool __rtrs_srv_change_state(struct rtrs_srv_sess *sess, old_state = sess->state; switch (new_state) { case RTRS_SRV_CONNECTED: - switch (old_state) { - case RTRS_SRV_CONNECTING: + if (old_state == RTRS_SRV_CONNECTING) changed = true; - fallthrough; - default: - break; - } break; case RTRS_SRV_CLOSING: - switch (old_state) { - case RTRS_SRV_CONNECTING: - case RTRS_SRV_CONNECTED: + if (old_state == RTRS_SRV_CONNECTING || + old_state == RTRS_SRV_CONNECTED) changed = true; - fallthrough; - default: - break; - } break; case RTRS_SRV_CLOSED: - switch (old_state) { - case RTRS_SRV_CLOSING: + if (old_state == RTRS_SRV_CLOSING) changed = true; - fallthrough; - default: - break; - } break; default: break; From patchwork Fri May 28 11:30:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286761 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 1E6ADC4708C for ; Fri, 28 May 2021 11:30:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0215961378 for ; Fri, 28 May 2021 11:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233879AbhE1LcI (ORCPT ); Fri, 28 May 2021 07:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbhE1LcE (ORCPT ); Fri, 28 May 2021 07:32:04 -0400 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 797D3C0613CE for ; Fri, 28 May 2021 04:30:25 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id ci15so1465287ejc.10 for ; Fri, 28 May 2021 04:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9kAUJfWVvvjbapa2QAkBuBvSpUh0vDXAcb8xqlnfA30=; b=huqE9ehbfVGaMa1H8R9P5WiknsFtGTbWEvAR68iq5O3Yo/SpSd4TTWs8lrIKzfeFDh 4cnHYwwVXFAWmtykX7M9nZdR+PX7FWsdfqleZw1xcV87P4gIY8k7pZ0LMhgAgi0Kp7Bc RdO/hC2Ard9QXvuL6mu2+L5zxaBraqkafF54hrnoVdHC2iPkjdmZOmX5uW0HUim4jxc4 EV2US+h7wpdocAKxcr9A5pPsbzdZzb0Lx/6JOnc7vHD1pA7fIJUP8RnV38WzWC+Vft8D sbTJZa8oUpgkah9uefQ8HQrmNMo74CPj8NgrNJ0LLZU3685apBVNwWA08uFTaKtwI3rv kYOA== 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=9kAUJfWVvvjbapa2QAkBuBvSpUh0vDXAcb8xqlnfA30=; b=PWAobVZB22GIsYlq42Fqi2zngH34oDb96UUv1BqlFOLaDGTkMDXeCfCUBNK9qszdep dDbM4ah/JRarZ9eQzqLHx55x4VhSpos1f+giDJYLsSb6HnmC9vL0amrXSEmXT/eIPX6q ARsynpWFk8MJm3YO647DZEcCodl9nQDWVytGiL8jksL2EN2hhEKwu2AXnnz09E+0+NKF PYbYGLDr9VgntiZVXKOFo8bGBkoezNRCHiasPd0KQmExvFZhe38kR3qUk9MO+EH5VO0n dBpGjsqbtcJqEeFCAIG7f/QRYP2V0ykZpfUeyMKZji1gVSV28feR2vxr4XYWoUB1Ym0z xqKQ== X-Gm-Message-State: AOAM532oNlutqpbtc1M8j+kJ9CGlEPMMs/frxsp3s0L6eRlLkgSiCl0F tbNtOS3Y3G3otu17WNAoQwWDdOeVbnGA2w== X-Google-Smtp-Source: ABdhPJzGXcsDs/Rw/u8ouo0tVZEyJiUvY8Auom+Sb9JH6g/XCotG8RN3WoGuvBidnCseBQMDQxrhBw== X-Received: by 2002:a17:906:1189:: with SMTP id n9mr8610318eja.117.1622201423911; Fri, 28 May 2021 04:30:23 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:23 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 05/20] RDMA/rtrs: Change MAX_SESS_QUEUE_DEPTH Date: Fri, 28 May 2021 13:30:03 +0200 Message-Id: <20210528113018.52290-6-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) and the minimum chunk size is 4096 (2^12). Therefore the maximum sess_queue_depth is 65536 (2^16). Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Reported-by: kernel test robot --- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index 86e65cf30cab..d957bbf1ddd3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -47,12 +47,15 @@ enum { MAX_PATHS_NUM = 128, /* - * With the size of struct rtrs_permit allocated on the client, 4K - * is the maximum number of rtrs_permits we can allocate. This number is - * also used on the client to allocate the IU for the user connection - * to receive the RDMA addresses from the server. + * Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) + * and the minimum chunk size is 4096 (2^12). + * So the maximum sess_queue_depth is 65536 (2^16) in theory. + * But mempool_create, create_qp and ib_post_send fail with + * "cannot allocate memory" error if sess_queue_depth is too big. + * Therefore the pratical max value of sess_queue_depth is + * somewhere between 1 and 65536 and it depends on the system. */ - MAX_SESS_QUEUE_DEPTH = 4096, + MAX_SESS_QUEUE_DEPTH = 65536, RTRS_HB_INTERVAL_MS = 5000, RTRS_HB_MISSED_MAX = 5, From patchwork Fri May 28 11:30:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286763 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 B2C83C4708D for ; Fri, 28 May 2021 11:30:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9306661378 for ; Fri, 28 May 2021 11:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234379AbhE1LcJ (ORCPT ); Fri, 28 May 2021 07:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbhE1LcE (ORCPT ); Fri, 28 May 2021 07:32:04 -0400 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 C1D76C0613ED for ; Fri, 28 May 2021 04:30:26 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id y7so4483277eda.2 for ; Fri, 28 May 2021 04:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WpqYI7iC4VG2x5Qos9a4Y7Ie71t6WEBxgpfmSxlvJoc=; b=g5k7wvFp5tzt/0Zv4uovaVF9/G6mv8frfwZTHCEuhXI3LYYh9Pi3M36lhEwQOQGcfu wvuq8Kpc6d5XOXBcZ+nB9g5mjy3ixVuDWgPENTdPJXc+EnBiyPr7Wj/vBvUYgmSSblFf HaGhTB9JFyNfwVVSWET7WBx02J20Z2OQU4mqZwBPGMhAxMZ9MGEryD+pA9kt9WNFppLI JWzsa2adtUq6pt+gPJJ962F0Q22xeezN9DmfgnpsN+oRPGnVLfhkuMq6NsXC/0UG7XfW hOMGHp8OboYoZecSe2XhI23tG14g9Bol9i7Qfkf+bc3hTXhr36rBcQEhd3XZB3vIV04Z qmJg== 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=WpqYI7iC4VG2x5Qos9a4Y7Ie71t6WEBxgpfmSxlvJoc=; b=erv80S1c0m4nxnHapatl/1NPi/nWlrdXlNzvzfeX5TZNg22QVz4sjJ5PjyVZmftroZ 3Sel8Vu53Ft8nzOGODKfZXhXjL9kWcNxBOkuyue8ajW3gz74vswA33s+NPIDKx9xpN6p 055e3ANJfBrgL6oeSdxVFYvonNPdXtLkfEQWtw1yxufZ7/gzCjZeYIr/hjtgpU1h15e3 v7SL62233HDPpu33rzxRIbTZdEGrXUq0sXxPphtfOliPoGFn0xZFxRl3EfPujyQWLily 3fpF6hZw7Jqg9ZU9GjXzu1EaZlG8J5cNcZ0N8OrNDSX8WupEEgrLNGb/fYqsTQ12+LCT nGyQ== X-Gm-Message-State: AOAM530bdHtqA/SJSOUmWqZ13unPqef+MGGpbYStRZzsOr4u3PwPp28M YJw+pye6ySHj5xJx1tMFhiNOJ3Z75APBuw== X-Google-Smtp-Source: ABdhPJyZglVOfml7OfF1YTzLu8mAqVzS2FOGFLetdUy8wbav04oIzVKx6x1Jc9DWMi8yU5jjxI7OZA== X-Received: by 2002:aa7:d30f:: with SMTP id p15mr9328423edq.264.1622201424727; Fri, 28 May 2021 04:30:24 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:24 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 06/20] RDMA/rtrs: Define MIN_CHUNK_SIZE Date: Fri, 28 May 2021 13:30:04 +0200 Message-Id: <20210528113018.52290-7-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim Define MIN_CHUNK_SIZE to replace the hard-coding number. We need 4k for metadata, so MIN_CHUNK_SIZE should be at least 8k. Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 1 + drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index d957bbf1ddd3..1705197b8c22 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -56,6 +56,7 @@ enum { * somewhere between 1 and 65536 and it depends on the system. */ MAX_SESS_QUEUE_DEPTH = 65536, + MIN_CHUNK_SIZE = 8192, RTRS_HB_INTERVAL_MS = 5000, RTRS_HB_MISSED_MAX = 5, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index aa0585c176c9..5cfc2e3f9596 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -2165,9 +2165,9 @@ static int check_module_params(void) sess_queue_depth, 1, MAX_SESS_QUEUE_DEPTH); return -EINVAL; } - if (max_chunk_size < 4096 || !is_power_of_2(max_chunk_size)) { + if (max_chunk_size < MIN_CHUNK_SIZE || !is_power_of_2(max_chunk_size)) { pr_err("Invalid max_chunk_size value %d, has to be >= %d and should be power of two.\n", - max_chunk_size, 4096); + max_chunk_size, MIN_CHUNK_SIZE); return -EINVAL; } From patchwork Fri May 28 11:30:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286765 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 DE697C4708F for ; Fri, 28 May 2021 11:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAC1461378 for ; Fri, 28 May 2021 11:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234443AbhE1LcK (ORCPT ); Fri, 28 May 2021 07:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233576AbhE1LcE (ORCPT ); Fri, 28 May 2021 07:32:04 -0400 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 C1E04C06138A for ; Fri, 28 May 2021 04:30:27 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id g7so4478406edm.4 for ; Fri, 28 May 2021 04:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hh/MJDuFEwUB9dA5kYACQ+u+GKMwUN2JMjjZ9Bs+lqc=; b=RPIir6Oe2gH1uPEmPZ3pKTSKmoINnAP0qu4aVbLuTHcNtxiID1LBKPo3Aba9JsUjEo cNw6rrgQ/NeKA6eQikcg89llNcex0McPaIjy39iY4pcvrxkgyTMHJlWSRClwmstCH7Pm WF7ijyj/EEAWnFJxR1Q5xicHkRP4BaKY5XP2s0UILNPa7ijqrtgRxfltAfMNQKVuHSU9 Ymsg4iPQD452PVIfagBcMARe0SxoxtpM9OVxhHIuz6EavpTp0ERZ4UDq1+6zvE7S3mz7 8SYITr5OboTWnuKZJmRro+0wzf7GNv337bCjc4ijXHzfMvsWT9io+Use3MKKfrar8zqa Nm/A== 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=Hh/MJDuFEwUB9dA5kYACQ+u+GKMwUN2JMjjZ9Bs+lqc=; b=mX3RsTUyP8vVGHIFfTaJIXke6y7Aqom5PilrRYk4iZb25yibDvaqrPLHHZUhxZtYXx wtaJa5FMaB1pA3WywNf77SFEfHck8xzWe3CcSZY+x8yrFUVU/g6+YLoVvT5VtyvFDLEd TG0X5GL5lWilW4hIQ2uFutfJy30ZUm6I86xj75yOEePFLiot8vz9EZzftHt89H/sez5X mmepA8KZIKHKGct5/HYcNXm3UAel5aYHXQvSB/VQLv22D9FB6tsOk/pibYtEnoLp9Spk RHcrkHDQmaeqWGXQMSPhRwUofePuZOBxEclahyYraMfgfWy0NLRjrpmTms2dMqGHpdy6 yV5A== X-Gm-Message-State: AOAM531vs722FekkelRb0GjSOPIrwpbIcrfg1TpZOATCU6uhC9Fm/E00 ybzqveu4bpwWJT69XVRHgQUt6T6oRgQxuw== X-Google-Smtp-Source: ABdhPJzWsUQ3h3twD/8/Grh1K/GwAKMmav20IrxtH06YdjnWKAEmtKEzYxgGj8usuzf/UX2A7HchhA== X-Received: by 2002:a05:6402:134d:: with SMTP id y13mr9382959edw.287.1622201425698; Fri, 28 May 2021 04:30:25 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:25 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Dima Stepanov , Dima Stepanov , Gioh Kim Subject: [PATCHv3 for-next 07/20] RDMA/rtrs: Use strscpy instead of strlcpy Date: Fri, 28 May 2021 13:30:05 +0200 Message-Id: <20210528113018.52290-8-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Dima Stepanov During checkpatch analyzing the following warning message was found: WARNING:STRLCPY: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Fix it by using strscpy calls instead of strlcpy. Signed-off-by: Dima Stepanov Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++-- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 97fa9da4dde4..f2005e57ea53 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1505,7 +1505,7 @@ static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt, if (path->src) memcpy(&sess->s.src_addr, path->src, rdma_addr_size((struct sockaddr *)path->src)); - strlcpy(sess->s.sessname, clt->sessname, sizeof(sess->s.sessname)); + strscpy(sess->s.sessname, clt->sessname, sizeof(sess->s.sessname)); sess->clt = clt; sess->max_pages_per_mr = max_segments; init_waitqueue_head(&sess->state_wq); @@ -2652,7 +2652,7 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, clt->priv = priv; clt->link_ev = link_ev; clt->mp_policy = MP_POLICY_MIN_INFLIGHT; - strlcpy(clt->sessname, sessname, sizeof(clt->sessname)); + strscpy(clt->sessname, sessname, sizeof(clt->sessname)); init_waitqueue_head(&clt->permits_wait); mutex_init(&clt->paths_ev_mutex); mutex_init(&clt->paths_mutex); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 5cfc2e3f9596..2ba6658c5e35 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -780,7 +780,7 @@ static int process_info_req(struct rtrs_srv_con *con, rwr = kcalloc(sess->mrs_num, sizeof(*rwr), GFP_KERNEL); if (unlikely(!rwr)) return -ENOMEM; - strlcpy(sess->s.sessname, msg->sessname, sizeof(sess->s.sessname)); + strscpy(sess->s.sessname, msg->sessname, sizeof(sess->s.sessname)); tx_sz = sizeof(*rsp); tx_sz += sizeof(rsp->desc[0]) * sess->mrs_num; @@ -1261,7 +1261,7 @@ int rtrs_srv_get_sess_name(struct rtrs_srv *srv, char *sessname, size_t len) list_for_each_entry(sess, &srv->paths_list, s.entry) { if (sess->state != RTRS_SRV_CONNECTED) continue; - strlcpy(sessname, sess->s.sessname, + strscpy(sessname, sess->s.sessname, min_t(size_t, sizeof(sess->s.sessname), len)); err = 0; break; @@ -1715,7 +1715,7 @@ static struct rtrs_srv_sess *__alloc_sess(struct rtrs_srv *srv, path.src = &sess->s.src_addr; path.dst = &sess->s.dst_addr; rtrs_addr_to_str(&path, str, sizeof(str)); - strlcpy(sess->s.sessname, str, sizeof(sess->s.sessname)); + strscpy(sess->s.sessname, str, sizeof(sess->s.sessname)); sess->s.con_num = con_num; sess->s.recon_cnt = recon_cnt; From patchwork Fri May 28 11:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286767 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 A0CCAC4708D for ; Fri, 28 May 2021 11:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BADF61378 for ; Fri, 28 May 2021 11:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234615AbhE1LcL (ORCPT ); Fri, 28 May 2021 07:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbhE1LcE (ORCPT ); Fri, 28 May 2021 07:32:04 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 985A5C06138B for ; Fri, 28 May 2021 04:30:28 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id df21so4477669edb.3 for ; Fri, 28 May 2021 04:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o6sNxd83hFhEZUh1S6gveGbG3IqoLQunL0auufAbUjg=; b=La+ouytXrKrOGSidxeHfO2uWKLC8xPOV5igXjERptS771qwR8qwKKmOYZgYE8IJaEk raDfizovayjV179A14LvQw/uVIZroCdyXPCIpv0weMFNfTatGtvpvoXHq0bRrQr3XfPW Gmv04gnbFfgdlJwmNMrHDr3ZQ/mro5ycmY86egP4bfoFa9DYbdx2eFbgvhV4oPai2okt aAP0LB88LPn6GD4eq1BNd80vq6Yxy/ckLDB6AJ4An8fF7efLcxJoM6xKIgbnrfpcnycw Mzr1+b633BRxNgmrCJrsq5Z40QjWTEPLrd34JRHujN/EfEF6JIbFIdnbiMTeaSohWSJ5 twow== 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=o6sNxd83hFhEZUh1S6gveGbG3IqoLQunL0auufAbUjg=; b=EnzZggGGzUe/7O1NG4WYapLtjsIKIWtezurCeTRnqbRADKMJPIynBZlOnMUy4TCPOU mdq7bd4zOqO9WCH1C944eKcAQeXBLJLqxjTlG8asacoKG1dHbWHI7nqE+rU+VNiC7A8i WDujGeRR7DyfPZZ7DTapVMe0oms6BFBWc0OqY4rhnVj9a6vKyGKDwU2nfPFl4BZiPTTK fc1bA6LQasYTHcSvKOqzCaGmnOUeZg1olevYULfzC6ezLG3JNgv5B6CwsWShip2sWkWp Vppw6rxzRSA0Q9Vnww7MdsOuT6e4VNkvH0n2fAGMjFuMyypGslIEFoxhQ75NZknDRL7d rgng== X-Gm-Message-State: AOAM53031tQentMbQrv9BlJoiJl1Q9eZARzHYByo8wnGzFDFG07lVWAU F+8Y6dZvucoKwHFt/bxYaA9NdlSBDGenMw== X-Google-Smtp-Source: ABdhPJwmi38TKnLtvyZGcoxkOPtliOLeaV3WjRA4xcwEFbCdRLka6PT/9sTOVhPp+hFNU9w9yA1b/g== X-Received: by 2002:a05:6402:1a:: with SMTP id d26mr9588934edu.105.1622201426652; Fri, 28 May 2021 04:30:26 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:26 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 08/20] RDMA/rtrs-clt: Kill rtrs_clt_{start,stop}_hb Date: Fri, 28 May 2021 13:30:06 +0200 Message-Id: <20210528113018.52290-9-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang The two wrappers are not needed since we can call rtrs_{start,stop}_hb directly. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index f2005e57ea53..e34d5eadcfb2 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1449,16 +1449,6 @@ static void rtrs_clt_init_hb(struct rtrs_clt_sess *sess) rtrs_wq); } -static void rtrs_clt_start_hb(struct rtrs_clt_sess *sess) -{ - rtrs_start_hb(&sess->s); -} - -static void rtrs_clt_stop_hb(struct rtrs_clt_sess *sess) -{ - rtrs_stop_hb(&sess->s); -} - static void rtrs_clt_reconnect_work(struct work_struct *work); static void rtrs_clt_close_work(struct work_struct *work); @@ -2098,7 +2088,7 @@ static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_sess *sess) */ synchronize_rcu(); - rtrs_clt_stop_hb(sess); + rtrs_stop_hb(&sess->s); /* * The order it utterly crucial: firstly disconnect and complete all @@ -2291,7 +2281,7 @@ static int init_conns(struct rtrs_clt_sess *sess) if (err) goto destroy; - rtrs_clt_start_hb(sess); + rtrs_start_hb(&sess->s); return 0; From patchwork Fri May 28 11:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286771 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 C0918C47087 for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A03D7613D1 for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234639AbhE1LcL (ORCPT ); Fri, 28 May 2021 07:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234224AbhE1LcF (ORCPT ); Fri, 28 May 2021 07:32:05 -0400 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 40B6FC06138C for ; Fri, 28 May 2021 04:30:29 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id e12so4868824ejt.3 for ; Fri, 28 May 2021 04:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XMBpTRUY+kS2EBYl2UDMjKmmroGOrL4HkncHzS5JY3g=; b=ZnXuOFF+x0hnjangfJ7BE95LfIp71qGdFCOK1AExkDXbaaxkHTTTBT+j8pdofXX2Zk DJrbTlLC3ivoHlewbiY+elHayTa4FW2WMlQ6MlgAoiG4C1YdAURwMPKia0OxErZNq0RH LfsV0LEdxr7zBPhZr0Z//DbBISsBltdTFRH21oZRlyZEFAu8NdidbuICTRosFyFusJ3F 4dYcKY6ljs42r3SrJGee1+vR1GxQU0xXbijxtfnmNUtnK+93uZEQ1dR1i82H0427Sw7V hwhwbv5XcdgJLQtY3bjcyg0/rBoJxZ/RdD8/Jr0CfUkffjPTcWuRgIGOUA4plAgamkZM Y2OA== 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=XMBpTRUY+kS2EBYl2UDMjKmmroGOrL4HkncHzS5JY3g=; b=JJPe3vRknAiukv+ZM24S2jqn+d71/6xgFXdbx/Q4z90j9nQmKQEKQkT4MZaqMlwAIg gG3qboaE/wdYafGVKrSNq5jrrN2EjQ7a4ptc8rQxAuKPrrtdqI6Cb5WVahD5MTkABGlg CiG3bfa+1YGBZkAog9ir5TaHNqMEZVSaZFH9A5oNcmHOOPDaMaT6GNmYGkjmyqBBjzt2 cLjy0sPG/fwaaZF4u7hvG8eVWcQM1mKmyPjUH3dty1NnnE5JRTuT5oz8qJLAu9vON78+ nqiFMWNvV6kHdBkweSn1xqYkZmHTW1a+uigc639y0He2lQ89BxYdgoj2lwIyK4S8HUNO Cozw== X-Gm-Message-State: AOAM53156EsYOgWH/s53Ry+w3VTNJ+j8XaciJRzohRD4MgfntCAWuXNP aRhBsPvHWIHggz22J/Q9c1vAOO3d37iZNw== X-Google-Smtp-Source: ABdhPJwZttvkHkSgTO9ZtRqx3Jq6mxsPDZzCa38r1KqRVncMWR7XB0IcoxPBr8nEf1LVL0kuqkloZQ== X-Received: by 2002:a17:906:dfd1:: with SMTP id jt17mr787800ejc.486.1622201427678; Fri, 28 May 2021 04:30:27 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:27 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 09/20] RDMA/rtrs-clt: Kill rtrs_clt_disconnect_from_sysfs Date: Fri, 28 May 2021 13:30:07 +0200 Message-Id: <20210528113018.52290-10-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang The function is just a wrapper of rtrs_clt_close_conns, let's call rtrs_clt_close_conns directly. Signed-off-by: Guoqing Jiang Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 5 +---- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 2 +- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index 7d53d18a5004..4ee592ccf979 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -250,7 +250,6 @@ static ssize_t rtrs_clt_disconnect_store(struct kobject *kobj, const char *buf, size_t count) { struct rtrs_clt_sess *sess; - int ret; sess = container_of(kobj, struct rtrs_clt_sess, kobj); if (!sysfs_streq(buf, "1")) { @@ -258,9 +257,7 @@ static ssize_t rtrs_clt_disconnect_store(struct kobject *kobj, attr->attr.name, buf); return -EINVAL; } - ret = rtrs_clt_disconnect_from_sysfs(sess); - if (ret) - return ret; + rtrs_clt_close_conns(sess, true); return count; } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index e34d5eadcfb2..e87796a556c0 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1859,7 +1859,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, return -ECONNRESET; } -static void rtrs_clt_close_conns(struct rtrs_clt_sess *sess, bool wait) +void rtrs_clt_close_conns(struct rtrs_clt_sess *sess, bool wait) { if (rtrs_clt_change_state_get_old(sess, RTRS_CLT_CLOSING, NULL)) queue_work(rtrs_wq, &sess->close_work); @@ -2831,13 +2831,6 @@ int rtrs_clt_reconnect_from_sysfs(struct rtrs_clt_sess *sess) return err; } -int rtrs_clt_disconnect_from_sysfs(struct rtrs_clt_sess *sess) -{ - rtrs_clt_close_conns(sess, true); - - return 0; -} - int rtrs_clt_remove_path_from_sysfs(struct rtrs_clt_sess *sess, const struct attribute *sysfs_self) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 4c52f30e4da1..919c9f96f25b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -202,7 +202,7 @@ static inline struct rtrs_permit *get_permit(struct rtrs_clt *clt, int idx) } int rtrs_clt_reconnect_from_sysfs(struct rtrs_clt_sess *sess); -int rtrs_clt_disconnect_from_sysfs(struct rtrs_clt_sess *sess); +void rtrs_clt_close_conns(struct rtrs_clt_sess *sess, bool wait); int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, struct rtrs_addr *addr); int rtrs_clt_remove_path_from_sysfs(struct rtrs_clt_sess *sess, From patchwork Fri May 28 11:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286769 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 C8F00C4708C for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE7E561378 for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234667AbhE1LcM (ORCPT ); Fri, 28 May 2021 07:32:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233711AbhE1LcF (ORCPT ); Fri, 28 May 2021 07:32:05 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07080C061574 for ; Fri, 28 May 2021 04:30:30 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id t3so4456429edc.7 for ; Fri, 28 May 2021 04:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hlpwZoL+DNah27/Nz5DhzxgnHNjAukENDwvMU97btBY=; b=LT/9+d71olBml3QMg/TxbIugugnEp8gA8f4wHwmccu7fg1KMQcd5abLz0ienfJbwx0 X2Ctf8IG7ZVlq9URgAKzMlYJ55vBSl5kgvBryKnWLJczXf0BxpgmRoW0uxipYBA8vYOb pZRUJpBuTrJywvBs0cmTFJdsdAsQDQ1puYfdDXD7qHZZJLCBVEIKTzafuKouBFCBvXT2 8qtzOke8JYjEsiXa1IOzE8r1fetTLqzUZBsn5fiZsEGTCwsrjW7K26wgqijaFWmxUS10 Br7KEZT83XcmxZOJEmijWaB20Y9mii41eXzlvmTlmkHwJv+uWhK19F1gaJZ9rwJoYMDR g1Yg== 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=hlpwZoL+DNah27/Nz5DhzxgnHNjAukENDwvMU97btBY=; b=ct/0o0vlQ1e64XOt4GooRpHMnFYwGDS/euR8W7fueXki9Nw3UwU/EirDhSwEE+d6gh eadZeEvEc97HXN+/wWE/wae73rseCaAIGqplrPK50Gse+T3bjTsCwnIM1smgEzdFcQAF eQceB87H2a/AXwcjltEQ15QrLumr6ZfIGU9E6JbEicuUvrQcpVnxmMhfjASLLtMwwPOM NdXL8EYgRQXw/7Q8aSFRmEfr6ccrQGZJpm50XeXwnrKK/UH0XkG/LvjzvdK1fxiw8+yH t8lToo6HlZ1660UrnQngA5JSE4XawFVKwhInLxdf34fo4ntJoUQJmUVANO7YKXe9c+OY IX6w== X-Gm-Message-State: AOAM532mOUZRgIF0h5YLBDVtYUFsD/Rkutbk4gitIiUfESvhrPuMGxLF AuAcgBLt5n5kTszcDuOVVugczQauREkBnA== X-Google-Smtp-Source: ABdhPJz4mQk4YwCnoOch+hiFabvIkWXkyvkIDE2YHf3I48LvGpecOQjKfaQ0ULC/evjdjqNymKKHbQ== X-Received: by 2002:aa7:c04c:: with SMTP id k12mr9497056edo.252.1622201428502; Fri, 28 May 2021 04:30:28 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:28 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 10/20] RDMA/rtrs-srv: Kill __rtrs_srv_change_state Date: Fri, 28 May 2021 13:30:08 +0200 Message-Id: <20210528113018.52290-11-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang No need since the only user is rtrs_srv_change_state. Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 2ba6658c5e35..840a3423f749 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -67,13 +67,13 @@ static inline struct rtrs_srv_sess *to_srv_sess(struct rtrs_sess *s) return container_of(s, struct rtrs_srv_sess, s); } -static bool __rtrs_srv_change_state(struct rtrs_srv_sess *sess, - enum rtrs_srv_state new_state) +static bool rtrs_srv_change_state(struct rtrs_srv_sess *sess, + enum rtrs_srv_state new_state) { enum rtrs_srv_state old_state; bool changed = false; - lockdep_assert_held(&sess->state_lock); + spin_lock_irq(&sess->state_lock); old_state = sess->state; switch (new_state) { case RTRS_SRV_CONNECTED: @@ -94,17 +94,6 @@ static bool __rtrs_srv_change_state(struct rtrs_srv_sess *sess, } if (changed) sess->state = new_state; - - return changed; -} - -static bool rtrs_srv_change_state(struct rtrs_srv_sess *sess, - enum rtrs_srv_state new_state) -{ - bool changed; - - spin_lock_irq(&sess->state_lock); - changed = __rtrs_srv_change_state(sess, new_state); spin_unlock_irq(&sess->state_lock); return changed; From patchwork Fri May 28 11:30:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286773 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 F422FC4708D for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4B6661378 for ; Fri, 28 May 2021 11:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233884AbhE1LcN (ORCPT ); Fri, 28 May 2021 07:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234259AbhE1LcF (ORCPT ); Fri, 28 May 2021 07:32:05 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD459C061760 for ; Fri, 28 May 2021 04:30:30 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id g7so4478584edm.4 for ; Fri, 28 May 2021 04:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1QD3hWGQenuZYQN4gR9I/abqD2AvoXdG7l4VYDuQ9mM=; b=YoN9LKKUdEjhWlKtaVKWazz9wEUz41OOdgQ8jJQJ7Yoh3J/kVIYAgRS6zGjXC7zn1q TzsIkHi2elwaxNc6cTjdjPc6hRVJKgkZQLskJ66OvoYsLxOWpKa0fDHMAo16tnDWbjrl Xu1/hvYCP8qKUaOSLK+5rjf9/Nz6WkaLdh67fIFyDthM7Tg1TuyWJa6DNOl8Xfbs2t+Q z73e6UhLIZcCMmAyQZoMDEDj6PkmscgOrG1wkdfx9z1Wckm5VM6JB2Pzws++lICvQL9d ZRAgrl1GS0uUp6RCgNpwnFI6A321UHH4EEAepaKAYMSRPzm3gnAHf00fKJwXd9HcGldf qepQ== 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=1QD3hWGQenuZYQN4gR9I/abqD2AvoXdG7l4VYDuQ9mM=; b=gwixe0KYcamcqFeKk3MgPR4m5wlxzKlUpNmCaOa6dPM6/Tz48VsAz6WChoAvtf0DT6 gc3pyjoQe655gvi532jAjw/TYnlWSeDXRQCmG1NaKzEscJFTOcdccW3PxO3dY3yAS1CM qab4lddhvmP7to58qo4WO7i/jjJMSBetVRnfijLffVugAPPJEHLqxV7484H8cH0jvztL klVdQVMC0YAdPYrE1nQpMaB78nxvo8hOGgZvMB7cKw2t6rfYlhOjL0o/jQT75MmAC4L+ jhp3Zr+4/DdCkClpRq2RO/2EATrrOaDdxvSt1pTSWo//fif6RYOG6qSpLJ3KeLalAjFt 97hQ== X-Gm-Message-State: AOAM530ZxAP0I+hFQYmLBt10oaRZ0eCw0iaWonrmqMfoYEaXmhcVDb90 sW0IDKHK6MpxM7FwKlLLC4YN/WH7wVYrzA== X-Google-Smtp-Source: ABdhPJzBOPAVMKTTX0E/oMsL+AE34UNcOR0EZcphCEEM2E1KdLy2C8cwxQe2uturptM1JsFGhWrHUQ== X-Received: by 2002:aa7:c499:: with SMTP id m25mr9223354edq.109.1622201429311; Fri, 28 May 2021 04:30:29 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:29 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Guoqing Jiang , Guoqing Jiang , Gioh Kim Subject: [PATCHv3 for-next 11/20] RDMA/rtrs-clt: Remove redundant 'break' Date: Fri, 28 May 2021 13:30:09 +0200 Message-Id: <20210528113018.52290-12-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Guoqing Jiang It is duplicated with the very next line Signed-off-by: Guoqing Jiang Reviewed-by: Md Haris Iqbal Signed-off-by: Gioh Kim --- 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 e87796a556c0..79324138df9a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -655,7 +655,6 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) rtrs_err(con->c.sess, "rtrs_post_recv_empty(): %d\n", err); rtrs_rdma_error_recovery(con); - break; } break; case IB_WC_RECV: From patchwork Fri May 28 11:30:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286775 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 F3EB2C4708E for ; Fri, 28 May 2021 11:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8F4A613D1 for ; Fri, 28 May 2021 11:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbhE1LcN (ORCPT ); Fri, 28 May 2021 07:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233734AbhE1LcG (ORCPT ); Fri, 28 May 2021 07:32:06 -0400 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 A4D20C06174A for ; Fri, 28 May 2021 04:30:31 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id j9so4464614edt.6 for ; Fri, 28 May 2021 04:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UFAQcFQf4D29+rb3R9Oj+VbFp3/JqstR5WQkYTNsMzA=; b=K5E7JFqm+27uKc4Ahy1Glp+OvCBYV7s/EAd3Om1CzM/r90UmaU9x+wRnoYz/zNhJ4l dKGhyBnLddtvqW0FGiBCqDTSoVI/kc1WwNvVjLhHbcfvIiPRgXAfTQBWHksKNNh3g9dh WAKrcSzOkjje7VNURaS8yCoQW1877VDVt2Oe4sud9pDnIuMPrhGpo6J2qPjnzSh0IEEn MfxSVqaBDRQde0aSOHXcLnACf0ptBVJial/rr5+weDedZS315HeZmXJNvsrJI9t69qQn kfWLFl+O2jDwkPgAY7MExIvLjMy5xE0oX/dt04Kqn5lQUOGGSDQheANBWestnlgjbM1x yL3w== 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=UFAQcFQf4D29+rb3R9Oj+VbFp3/JqstR5WQkYTNsMzA=; b=EqK5qX5kFjqQGg9ofkdA+XGoCG3hbCMQNE3U3TzhLMAtSdix8FK1w6+r34tMkheEwM 9f+KSQZLmi7iZdDbEiaZSo7S4xaLGYN6jbn5eAJQauouz/7/KMEgyPKO6DXvPTDPD0SW FFlBqFdR7gnkxjMRRYWYsSkNu9rILiG5mruLJXXjWgyiawdgk7OndwxeGhYlvEmv1+k5 ePA+f0MOWqQHk9qo44ZIwvDc+31oTa1PsgQG4fo5MIAnNSzz+32FquSX7bedZ6Qs3WRE LxHPYVdPmBmFZaRcfr+wazBbyODD02OVi2RKHcQWIUxGJO3sYTPpWXL2n7KaW2Bc3YOj F9vA== X-Gm-Message-State: AOAM530s1INyqc5w9yCR1JaMLP3hYd6GP5V4OEW6ucPXYsFZaf1lAFlF 3/Ifh/fdfbzBmHAzUe+tKgp3wMWBClrmZg== X-Google-Smtp-Source: ABdhPJxBCMsratx5yMro5kqFto/jfrYyk8gDOn8i7VWBuASt+xq0sb0k4TvwOgMi4f8WnfEG0QptiA== X-Received: by 2002:a50:fb17:: with SMTP id d23mr9265353edq.338.1622201430116; Fri, 28 May 2021 04:30:30 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:29 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Gioh Kim Subject: [PATCHv3 for-next 12/20] RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its stats Date: Fri, 28 May 2021 13:30:10 +0200 Message-Id: <20210528113018.52290-13-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Md Haris Iqbal When get_next_path_min_inflight is called to select the next path, it iterates over the list of available rtrs_clt_sess (paths). It then reads the number of inflight IOs for that path to select one which has the least inflight IO. But it may so happen that rtrs_clt_sess (path) is no longer in the connected state because closing or error recovery paths can change the status of the rtrs_clt_Sess. For example, the client sent the heart-beat and did not get the response, it would change the session status and stop IO processing. The added checking of this patch can prevent accessing the broken path and generating duplicated error messages. It is ok if the status is changed after checking the status because the error recovery path does not free memory and only tries to reconnection. And also it is ok if the session is closed after checking the status because closing the session changes the session status and flush all IO beforing free memory. If the session is being accessed for IO processing, the closing session will wait. Fixes: 6a98d71daea18 ("RDMA/rtrs: client: main functionality") Signed-off-by: Md Haris Iqbal Reviewed-by: Gioh Kim Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 79324138df9a..88a1c93f244a 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -813,6 +813,9 @@ static struct rtrs_clt_sess *get_next_path_min_inflight(struct path_it *it) int inflight; list_for_each_entry_rcu(sess, &clt->paths_list, s.entry) { + if (unlikely(READ_ONCE(sess->state) != RTRS_CLT_CONNECTED)) + continue; + if (unlikely(!list_empty(raw_cpu_ptr(sess->mp_skip_entry)))) continue; From patchwork Fri May 28 11:30:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286779 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 ECCFEC4708D for ; Fri, 28 May 2021 11:30:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCA1061378 for ; Fri, 28 May 2021 11:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234792AbhE1LcP (ORCPT ); Fri, 28 May 2021 07:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbhE1LcH (ORCPT ); Fri, 28 May 2021 07:32:07 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8150DC061761 for ; Fri, 28 May 2021 04:30:32 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id g7so4478671edm.4 for ; Fri, 28 May 2021 04:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DKurLA/0gHvT4nPGy7wrh43l+njp8QOj+CWKGl5rTa8=; b=K/j810iT6xofVAAj24od4Pmud41YR/pvDYPFUBy0vGmv+6WZfq1r8Pz27u188S3xGf deMToA8htysH8EbX71rh1PbKCQOHkfYe4BiuCEm/Yl3xNZOhuau2a3ZYTVtB4ou08Slm p2RRaboGdRsM1LRyzMFhusP5GtaGU3X9ZVOIuRpKhPvvE6cTsihhuBO9/gS1zKJBtZJ5 lK/1GlqAJPa/kSH9KkxdAbsfo0WBHHD2dR4zbr4QCxCW/hRemWH6bW7+g75gyKMdhXuh nQfrYzsGB73mslExiYmMb/OuRQm/wVye/O3fcacra/HOIhLvo8C2j765DcTd94pby5Zz RYrQ== 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=DKurLA/0gHvT4nPGy7wrh43l+njp8QOj+CWKGl5rTa8=; b=i232Pv9y8faAUCKsrXmy9GxgKJmgNEIRTOpi4/pbz1bedXrHWC+1EDcj1niRgEHijn Q0CGMi2xE8We3PfudGuDDk8TzOBTSeJMgvQt5ldQnsGad78sWwX+iOaQH+1/Q0+ySjdP LNdFYivyuEx935YxvWxzFT4USIM+B8IxLJq9KQCl6PDa6ISbPqX3p1cP1gZY7JuhCzk9 04uIRie2poBe6YEalKpA6UTy4d5/mmq+HtPl8NibsTaeypzqfjJ1R3zEkT4WuVwwCqK9 zqbh4NPI3AWvETdET0FAEdCW71/4wSExNHzP0lH3m+PQuMd7K1ylF9sjxu6cjQb7CHdx V6pQ== X-Gm-Message-State: AOAM530F0SKKmjHaLuXXEx8K0qQiUn6W2sTE5EQ955h5xuK2CVlbiFD7 aktq2ELidSZxxr0mq5js95ffgV5pFkcyzw== X-Google-Smtp-Source: ABdhPJxvpYX2OYK9IaYZPxMFwk2pPwos+HnxHv3Ik5dBla2SrtbJpkmVH1ihM81Yu1TMG5s6c7C5Uw== X-Received: by 2002:aa7:cb48:: with SMTP id w8mr9408738edt.12.1622201430948; Fri, 28 May 2021 04:30:30 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:30 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Gioh Kim Subject: [PATCHv3 for-next 13/20] RDMA/rtrs-srv: Replace atomic_t with percpu_ref for ids_inflight Date: Fri, 28 May 2021 13:30:11 +0200 Message-Id: <20210528113018.52290-14-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Md Haris Iqbal ids_inflight is used to track the inflight IOs. But the use of atomic_t variable can cause performance drops and can also become a performance bottleneck. This commit replaces the use of atomic_t with a percpu_ref structure. The advantage it offers is, it doesn't check if the reference has fallen to 0, until the user explicitly signals it to; and that is done by the percpu_ref_kill() function call. After that, the percpu_ref structure behaves like an atomic_t and for every put call, checks whether the reference has fallen to 0 or not. rtrs_srv_stats_rdma_to_str shows the count of ids_inflight as 0 for user-mode tools not to be confused. Fixes: 9cb837480424e ("RDMA/rtrs: server: main functionality") Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang Signed-off-by: Gioh Kim --- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 12 +++--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 43 +++++++++++++------- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 4 +- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c index e102b1368d0c..520c24773229 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c @@ -27,12 +27,10 @@ ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, char *page, size_t len) { struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats; - struct rtrs_srv_sess *sess = stats->sess; - return scnprintf(page, len, "%lld %lld %lld %lld %u\n", - (s64)atomic64_read(&r->dir[READ].cnt), - (s64)atomic64_read(&r->dir[READ].size_total), - (s64)atomic64_read(&r->dir[WRITE].cnt), - (s64)atomic64_read(&r->dir[WRITE].size_total), - atomic_read(&sess->ids_inflight)); + return scnprintf(page, len, "%lld %lld %lld %lldn %u\n", + (s64)atomic64_read(&r->dir[READ].cnt), + (s64)atomic64_read(&r->dir[READ].size_total), + (s64)atomic64_read(&r->dir[WRITE].cnt), + (s64)atomic64_read(&r->dir[WRITE].size_total), 0); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 840a3423f749..631d37976518 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -111,7 +111,6 @@ static void rtrs_srv_free_ops_ids(struct rtrs_srv_sess *sess) struct rtrs_srv *srv = sess->srv; int i; - WARN_ON(atomic_read(&sess->ids_inflight)); if (sess->ops_ids) { for (i = 0; i < srv->queue_depth; i++) free_id(sess->ops_ids[i]); @@ -126,11 +125,19 @@ static struct ib_cqe io_comp_cqe = { .done = rtrs_srv_rdma_done }; +static inline void rtrs_srv_inflight_ref_release(struct percpu_ref *ref) +{ + struct rtrs_srv_sess *sess = container_of(ref, struct rtrs_srv_sess, ids_inflight_ref); + + percpu_ref_exit(&sess->ids_inflight_ref); + complete(&sess->complete_done); +} + static int rtrs_srv_alloc_ops_ids(struct rtrs_srv_sess *sess) { struct rtrs_srv *srv = sess->srv; struct rtrs_srv_op *id; - int i; + int i, ret; sess->ops_ids = kcalloc(srv->queue_depth, sizeof(*sess->ops_ids), GFP_KERNEL); @@ -144,8 +151,14 @@ static int rtrs_srv_alloc_ops_ids(struct rtrs_srv_sess *sess) sess->ops_ids[i] = id; } - init_waitqueue_head(&sess->ids_waitq); - atomic_set(&sess->ids_inflight, 0); + + ret = percpu_ref_init(&sess->ids_inflight_ref, + rtrs_srv_inflight_ref_release, 0, GFP_KERNEL); + if (ret) { + pr_err("Percpu reference init failed\n"); + goto err; + } + init_completion(&sess->complete_done); return 0; @@ -156,21 +169,14 @@ static int rtrs_srv_alloc_ops_ids(struct rtrs_srv_sess *sess) static inline void rtrs_srv_get_ops_ids(struct rtrs_srv_sess *sess) { - atomic_inc(&sess->ids_inflight); + percpu_ref_get(&sess->ids_inflight_ref); } static inline void rtrs_srv_put_ops_ids(struct rtrs_srv_sess *sess) { - if (atomic_dec_and_test(&sess->ids_inflight)) - wake_up(&sess->ids_waitq); + percpu_ref_put(&sess->ids_inflight_ref); } -static void rtrs_srv_wait_ops_ids(struct rtrs_srv_sess *sess) -{ - wait_event(sess->ids_waitq, !atomic_read(&sess->ids_inflight)); -} - - static void rtrs_srv_reg_mr_done(struct ib_cq *cq, struct ib_wc *wc) { struct rtrs_srv_con *con = to_srv_con(wc->qp->qp_context); @@ -1479,8 +1485,15 @@ static void rtrs_srv_close_work(struct work_struct *work) rdma_disconnect(con->c.cm_id); ib_drain_qp(con->c.qp); } - /* Wait for all inflights */ - rtrs_srv_wait_ops_ids(sess); + + /* + * Degrade ref count to the usual model with a single shared + * atomic_t counter + */ + percpu_ref_kill(&sess->ids_inflight_ref); + + /* Wait for all completion */ + wait_for_completion(&sess->complete_done); /* Notify upper layer if we are the last path */ rtrs_srv_sess_down(sess); diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h index 9543ae19996c..f8da2e3f0bda 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -81,8 +81,8 @@ struct rtrs_srv_sess { spinlock_t state_lock; int cur_cq_vector; struct rtrs_srv_op **ops_ids; - atomic_t ids_inflight; - wait_queue_head_t ids_waitq; + struct percpu_ref ids_inflight_ref; + struct completion complete_done; struct rtrs_srv_mr *mrs; unsigned int mrs_num; dma_addr_t *dma_addr; From patchwork Fri May 28 11:30:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286777 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 DA435C4708C for ; Fri, 28 May 2021 11:30:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA725613D1 for ; Fri, 28 May 2021 11:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbhE1LcO (ORCPT ); Fri, 28 May 2021 07:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233296AbhE1LcH (ORCPT ); Fri, 28 May 2021 07:32:07 -0400 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 2D951C061763 for ; Fri, 28 May 2021 04:30:33 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id j9so4464696edt.6 for ; Fri, 28 May 2021 04:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T0q/jMZciVG2+7gzShTXuQ1XSOgTAm8wBpLFKZiDIbE=; b=WMvSS6XOjck+Tz+YELscOm87RKF1soInSdKRuADY6bIh17LyctbGXMz8PCMLDxQudk YVzLCF+5g4PZMupVhIBMGb8v+Dh5o4JeZG8HhO3i6FzBklcZJtiIzlx47pCdmtnipAUp dC9rxNZFMSQkJx4gxCj8mCQM0ZgSvLHzzkYHnjlG5Aps8pH/atM2PxJlop1LKyUOG2aM 8VlCOwwQwm1BYKhMtbrH/kM9cVeo70kjN+/pPsRooNN6L/Ya96pGwGh2M2HwsmgV/Scs yjO9CZ1NBJiGVBWuTqUppI1mnS6/s1ha7t+IlFNO9NM+btiHNx6z7yd/ZYH2KPjK+1UY x+2A== 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=T0q/jMZciVG2+7gzShTXuQ1XSOgTAm8wBpLFKZiDIbE=; b=rLaaCol3gGnKs3PVmXwOUIKIn9xSl+BVG8qHErqy22M2847RT5yddz1wlpsqBoL05e MgtqZ9kGhkw7qCfonS1eE8RT55I+jjxt6jeTLIXp4fWPlWr+jf2QXNusm/9Pu7SfJTtn h1JInjPcrf9QftHGvF4Md+Wy5IlAsHuhraUN6S4L8kXzPc/zZC+HwawW7v3EPPO4Qm/h 9luOzd8t2A4G98u7N7DlQDYzUmOir469jN7U4Hsrcd6kGRpDoaDs+LO4cYbwK9t96njW iCChITKPKQV3qW61zg/PdeDYT3Dz7/gu0jHjyDlyez2binRM7fULNNy+47Xf9/6yeI+0 fIvA== X-Gm-Message-State: AOAM5308qAePpyvEEIi2Dt7GsjRQ0K2+LK9la39+DDZLLoFEzHgUbMlP SBW2TfPWZj+Ai1flXCHFIOcMsVxc2MdDcQ== X-Google-Smtp-Source: ABdhPJy9lIMEA5NoPxFckHl8EkB5SkNPvI5t2aLtGD1gQSJ2lKgcts47K1ERydZpTCg5BMPoqEntYw== X-Received: by 2002:a50:ef15:: with SMTP id m21mr9200172eds.226.1622201431696; Fri, 28 May 2021 04:30:31 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:31 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCHv3 for-next 14/20] RDMA/rtrs-srv: convert scnprintf to sysfs_emit Date: Fri, 28 May 2021 13:30:12 +0200 Message-Id: <20210528113018.52290-15-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c index 520c24773229..12c374b5eb6e 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c @@ -28,7 +28,7 @@ ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, { struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats; - return scnprintf(page, len, "%lld %lld %lld %lldn %u\n", + return sysfs_emit(page, "%lld %lld %lld %lldn %u\n", (s64)atomic64_read(&r->dir[READ].cnt), (s64)atomic64_read(&r->dir[READ].size_total), (s64)atomic64_read(&r->dir[WRITE].cnt), From patchwork Fri May 28 11:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286781 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 D7F7FC4708C for ; Fri, 28 May 2021 11:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B72D461378 for ; Fri, 28 May 2021 11:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234568AbhE1LcQ (ORCPT ); Fri, 28 May 2021 07:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234367AbhE1LcJ (ORCPT ); Fri, 28 May 2021 07:32:09 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15166C0613CE for ; Fri, 28 May 2021 04:30:34 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id j9so4464762edt.6 for ; Fri, 28 May 2021 04:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wr3oGd2AXGQRTQMnzq8qo5e2Hw8gAn5xCsknsd45XjQ=; b=JmJ8GDvajYFVGnoDmhVxib5sYfeig/zI1UxiZ0ChWWE5lAeBfn6yhgcvHeRU6x3LxO DbjmvAi7Z4ZTIBn8wjrzZoZofNUp2IjAOHCLw3V0GKZSD/PynQ34di9ve3ajszWd/r1D +mo8mpedjp3udQaj8WX4DLDalRQJXam4hSrK0H7dpw3YA6Pkn5PcP1jrapGpxGTVZAox MRDwC0b+S4PKqH13cIcxhcCpa80bDy4McQwe7F3yNI0GU1lmUgSuN/8bEjXWC1DLac1k aCJyAyodDUZXeIp4enc+Koef/UrsB8I38JEY6frW/lCT6YC4hKsOqv3GISltMN8KAp0t Ffcg== 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=wr3oGd2AXGQRTQMnzq8qo5e2Hw8gAn5xCsknsd45XjQ=; b=kDYeEkf592Ik4UYyO2Jf+76s9vuAXhnCtqAHAXT/1HHrLsKiJl4fcS0+N1+7BibHJj vNtCXfObAO/i3Xc95jdQaX4prIV0OVWPCXkG4HlZFdCbgC5TIInGbAFE/d70auX69FXu F0SyT2PBSIvbwAnbCySYvQS11dsbEIhkgG+//NQBh5mUDrRtbp68dxKSGnrVAtyWlaXl JxhTe/5kPk+W95hyQKICt45DZvoj1MtIatQTvqpDvnSvWWH3yEtq9UHL5xyh60oFsgqx 34YCNY6FC31Q/9NT8s0RqGjr14TIEwga2mXFCNMR520o+JLIvW2gSfB6N13FYaeR+W6s cHew== X-Gm-Message-State: AOAM532RVJV6NWucZU1iBwG+kTsdbxiiMigknHJBoMUbmpJJLyE0UDWG 4V1GBTC5Fm9Z8u+0mCofbIa9IIBB7Lwu0w== X-Google-Smtp-Source: ABdhPJwm+zxPNva/6u4ydjhdLD8A99d23bOCOefgl7eMURmwp1x7i1fPcRaxrB9/ThyACOhKotgh7A== X-Received: by 2002:a05:6402:684:: with SMTP id f4mr9622781edy.25.1622201432532; Fri, 28 May 2021 04:30:32 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:32 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 15/20] RDMA/rtrs: Do not reset hb_missed_max after re-connection Date: Fri, 28 May 2021 13:30:13 +0200 Message-Id: <20210528113018.52290-16-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim When re-connecting, it resets hb_missed_max to 0. Before the first re-connecting, client will trigger re-connection when it gets hb-ack more than 5 times. But after the first re-connecting, clients will do re-connection whenever it does not get hb-ack because hb_missed_max is 0. There is no need to reset hb_missed_max when re-connecting. hb_missed_max should be kept until closing the session. Fixes: c0894b3ea69d3 ("RDMA/rtrs: core: lib functions shared between client and server modules") Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index a7847282a2eb..4e602e40f623 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -376,7 +376,6 @@ void rtrs_stop_hb(struct rtrs_sess *sess) { cancel_delayed_work_sync(&sess->hb_dwork); sess->hb_missed_cnt = 0; - sess->hb_missed_max = 0; } EXPORT_SYMBOL_GPL(rtrs_stop_hb); From patchwork Fri May 28 11:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286783 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 E24F9C47087 for ; Fri, 28 May 2021 11:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5979613D1 for ; Fri, 28 May 2021 11:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234882AbhE1LcQ (ORCPT ); Fri, 28 May 2021 07:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbhE1LcK (ORCPT ); Fri, 28 May 2021 07:32:10 -0400 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 0DCF5C0613ED for ; Fri, 28 May 2021 04:30:35 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id h20so4890112ejg.1 for ; Fri, 28 May 2021 04:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jrwBwRyV/dgjPl2sDnRgTh6UPcWjl8bJANqc538yFec=; b=FfJlDuRjtk6zWTQPpprS0E/rQdubvyAwgamb72Bhz036F/1mZbFOcHCUd7VW7CBm3M H+IHnp7O1Nx6L4EO8utzfdmjo7fvqS/HpG/+eWoZ2UKUA3v/wRkacMZx/0jnLfTw2xFQ qB9vjz4ufAbRWIAJyikbD7etMigVk1qfDdDTjIm8HWC7N7fq2+VsPjIuSHbrnmdKkrXk 0tftzNnumblJa+9oaRDi0BYLP0mmauMGDvmgVG4QLN84vkx3It1ApdmYF0xW2AUJQgJv icow/plqKjMALdIdhvJhF/cfnZBkzGIZ3QusrBlZWl1geVfm+UzUIm8wQJAiqJ6jYe7F Vi5w== 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=jrwBwRyV/dgjPl2sDnRgTh6UPcWjl8bJANqc538yFec=; b=gzFC2jC5lHJsmpQKJoFwUpR5yoap6CSSrIrwWiXwXpbTonavuR6y1OjW4AnuQ51HLa f+YQTC+/old0mG1VbTliWqDyvpXvFlse/eYiWzBQ7Yxl5pmQpkxFrfHtOAbm/p1HXrtq 08N8qo+Yx9+lUtIXcmzG16zchvhypfFR/UPyBUyETLcxZZSI+omVhcguYtk0zXCPjfvm KznDHwJd6cKUy3gB3oN/vEI6AzAi71c31lbnkIJTMhCY+M3m+GZ7wMRGD8P4r0gH/3H3 ieKbzqT8LMNHblrLNmjhS2ANKbqY2k8dcfW2u048WcTWi+l+FEvjxiSivHqWrApbbgM3 Qujw== X-Gm-Message-State: AOAM5333dVo7hfU7Onn0+7MD3PZiNkGQ2Gj56yeue4a4SnOzXSBIR1ro 1jvuH8qhvGhvG8NUF8FMqnADFg1H2lan+A== X-Google-Smtp-Source: ABdhPJxdzCJSQ4WX0ubrVs6jCmmIh3KBt8J70lSqa3JsjeAvSAsSfjWlhkWXbepcFluni8aXjupEiQ== X-Received: by 2002:a17:906:2bd0:: with SMTP id n16mr8656804ejg.110.1622201433539; Fri, 28 May 2021 04:30:33 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:33 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim , Aleksei Marov Subject: [PATCHv3 for-next 16/20] RDMA/rtrs-srv: Duplicated session name is not allowed Date: Fri, 28 May 2021 13:30:14 +0200 Message-Id: <20210528113018.52290-17-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim If two clients try to use the same session name, rtrs-server generates a kernel error that it failed to create the sysfs because the filename is duplicated. This patch adds code to check if there already exists the same session name with the different UUID. If a client tries to add more session, it sends the UUID and the session name. Therefore it is ok if there is already same session name with the same UUID. The rtrs-server must fail only-if there is the same session name with the different UUID. Signed-off-by: Gioh Kim Signed-off-by: Aleksei Marov Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 631d37976518..78a861843705 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -753,7 +753,40 @@ static void rtrs_srv_sess_down(struct rtrs_srv_sess *sess) mutex_unlock(&srv->paths_ev_mutex); } +static bool exist_sessname(struct rtrs_srv_ctx *ctx, + const char *sessname, const uuid_t *path_uuid) +{ + struct rtrs_srv *srv; + struct rtrs_srv_sess *sess; + bool found = false; + + mutex_lock(&ctx->srv_mutex); + list_for_each_entry(srv, &ctx->srv_list, ctx_list) { + mutex_lock(&srv->paths_mutex); + + /* when a client with same uuid and same sessname tried to add a path */ + if (uuid_equal(&srv->paths_uuid, path_uuid)) { + mutex_unlock(&srv->paths_mutex); + continue; + } + + list_for_each_entry(sess, &srv->paths_list, s.entry) { + if (strlen(sess->s.sessname) == strlen(sessname) && + !strcmp(sess->s.sessname, sessname)) { + found = true; + break; + } + } + mutex_unlock(&srv->paths_mutex); + if (found) + break; + } + mutex_unlock(&ctx->srv_mutex); + return found; +} + static int post_recv_sess(struct rtrs_srv_sess *sess); +static int rtrs_rdma_do_reject(struct rdma_cm_id *cm_id, int errno); static int process_info_req(struct rtrs_srv_con *con, struct rtrs_msg_info_req *msg) @@ -772,10 +805,17 @@ static int process_info_req(struct rtrs_srv_con *con, rtrs_err(s, "post_recv_sess(), err: %d\n", err); return err; } + + if (exist_sessname(sess->srv->ctx, + msg->sessname, &sess->srv->paths_uuid)) { + rtrs_err(s, "sessname is duplicated: %s\n", msg->sessname); + return -EPERM; + } + strscpy(sess->s.sessname, msg->sessname, sizeof(sess->s.sessname)); + rwr = kcalloc(sess->mrs_num, sizeof(*rwr), GFP_KERNEL); if (unlikely(!rwr)) return -ENOMEM; - strscpy(sess->s.sessname, msg->sessname, sizeof(sess->s.sessname)); tx_sz = sizeof(*rsp); tx_sz += sizeof(rsp->desc[0]) * sess->mrs_num; From patchwork Fri May 28 11:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286785 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 C6342C4708D for ; Fri, 28 May 2021 11:30:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC518613D1 for ; Fri, 28 May 2021 11:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235045AbhE1LcT (ORCPT ); Fri, 28 May 2021 07:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbhE1LcL (ORCPT ); Fri, 28 May 2021 07:32:11 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC3E9C06138B for ; Fri, 28 May 2021 04:30:35 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id df21so4478111edb.3 for ; Fri, 28 May 2021 04:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kyDSwVDxaz/2g5qVIzlNJqfchWdo5hv8O+V3TRK4MSo=; b=bOR/KGXCJg5e//wyv6Z0me4gDtvi36mKP6wdrHE+HLg6QfeqAyuinzyYUIgJ9h5f7n Cz87kaqQYvSgW0ccf6FD2OIETl4wDnBLGsIVwGmdAJz1UX+Hbe8QZEM6syh5Oxoc/XAs YBKskIroHOXC/Tbog8rFZ3N4BiQrd9wRGhE+E65YTfXsqFZlBJzLLnHwFTKvYMF427GU oU6XdXls6yyI/CWF2AmJ+dhO0gqDnDqhjSuvwumUILYyFk3FwE+EebqXVLVbYlDD4arU CNiGCOz9coFU22s9Cw/BEIkJ0fe/Pc+FxQmg4OQ2nZEhtqYKGBnWY8VlZ/3RzY/FsKCe WvUg== 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=kyDSwVDxaz/2g5qVIzlNJqfchWdo5hv8O+V3TRK4MSo=; b=L6s7Q5ZjAQ1NxQhPlAICr13z50PuP/CMpZUej6hHT2mjsVzQcckY45WebNFnR98lnU BgTuh5WB1v425sLq6KGQ7CqnZJbUbVrgdmg4FCrirE1dMgWadFKs86mF7Tfq7DYsK6ou J+lkiS1/AVsuSukJSMNIv6Jd32swL78TLzSxwreAClju01OeIeTTrKdRI8m8o2sL1buJ pmz2CJgjG6JAXNYoGNd9TobxakCozE36cwKflFt4tyxnJ4QFW+ofSYtKDNN8CAY0K/ae mTYYBMYwvD9FAaSmMyvv8YoxDWNSwWtEEYrWoWlqrpnc9ORdLGhJRQGf8jWBayw1ZH/b kC4w== X-Gm-Message-State: AOAM532J0njKNv5zU7aiELHWn6BtfiKlXKP4+gdz/BXVW+kbVFHn9VvN /etouKmTQgmptNn0gYTXCjhwnZuE27NTxQ== X-Google-Smtp-Source: ABdhPJzNQI5Lo3miaOBEIwUvmixjxYPiS6hiNiTYGHai1OHEBLxv6EJcTqRRb8JqltLodmjNcJTPOw== X-Received: by 2002:a05:6402:2691:: with SMTP id w17mr9644741edd.140.1622201434336; Fri, 28 May 2021 04:30:34 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:34 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 17/20] RDMA/rtrs-srv: Fix memory leak of unfreed rtrs_srv_stats object Date: Fri, 28 May 2021 13:30:15 +0200 Message-Id: <20210528113018.52290-18-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim When closing a session, currently the rtrs_srv_stats object in the closing session is freed by kobject release. But if it failed to create a session by various reasons, it must free the rtrs_srv_stats object directly because kobject is not created yet. This problem is found by kmemleak as below: 1. One client machine maps /dev/nullb0 with session name 'bla': root@test1:~# echo "sessname=bla path=ip:192.168.122.190 \ device_path=/dev/nullb0" > /sys/devices/virtual/rnbd-client/ctl/map_device 2. Another machine failed to create a session with the same name 'bla': root@test2:~# echo "sessname=bla path=ip:192.168.122.190 \ device_path=/dev/nullb1" > /sys/devices/virtual/rnbd-client/ctl/map_device -bash: echo: write error: Connection reset by peer 3. The kmemleak on server machine reported an error: unreferenced object 0xffff888033cdc800 (size 128): comm "kworker/2:1", pid 83, jiffies 4295086585 (age 2508.680s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000a72903b2>] __alloc_sess+0x1d4/0x1250 [rtrs_server] [<00000000d1e5321e>] rtrs_srv_rdma_cm_handler+0xc31/0xde0 [rtrs_server] [<00000000bb2f6e7e>] cma_ib_req_handler+0xdc5/0x2b50 [rdma_cm] [<00000000e896235d>] cm_process_work+0x2d/0x100 [ib_cm] [<00000000b6866c5f>] cm_req_handler+0x11bc/0x1c40 [ib_cm] [<000000005f5dd9aa>] cm_work_handler+0xe65/0x3cf2 [ib_cm] [<00000000610151e7>] process_one_work+0x4bc/0x980 [<00000000541e0f77>] worker_thread+0x78/0x5c0 [<00000000423898ca>] kthread+0x191/0x1e0 [<000000005a24b239>] ret_from_fork+0x3a/0x50 Fixes: 39c2d639ca183 ("RDMA/rtrs-srv: Set .release function for rtrs srv device during device init") Signed-off-by: Gioh Kim Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 78a861843705..5639b29b8b02 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1503,6 +1503,7 @@ static void free_sess(struct rtrs_srv_sess *sess) kobject_del(&sess->kobj); kobject_put(&sess->kobj); } else { + kfree(sess->stats); kfree(sess); } } From patchwork Fri May 28 11:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286787 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 5B7BDC4708F for ; Fri, 28 May 2021 11:30:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F2E0613D1 for ; Fri, 28 May 2021 11:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235089AbhE1LcV (ORCPT ); Fri, 28 May 2021 07:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbhE1LcL (ORCPT ); Fri, 28 May 2021 07:32:11 -0400 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 C93D9C06174A for ; Fri, 28 May 2021 04:30:36 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id jt22so4837611ejb.7 for ; Fri, 28 May 2021 04:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rGxecfoeO7J0ch1dgSDW11rX626ORhUGBzNvZWcGShA=; b=Cgcv/98UiIRqhhuZqF7FD8/HEFCm8pszLlT52XBFR7W8n8Yu2lKkRZBn2kU7KTnnzk edV7AwhSpAJTHvEN9pD2ZCo4Xg0QeouhjpYjDTLCH3t01psZMAZuyn0fW+78Z89RjO8B ZZSIOmrUUzt7WZl8GPm18g6Ys42MRdES/yg/SZnLUflXssZR3zLg8gSXHhQ5xpv3oyyl 48CnWuk/bnVchWpfPWwA3986pUd7N+Q3cM3eyse8lsRYij+JwGLzlBmnt4sTJ2E6RPIY 7vZ0Kken8tnIAVivbnKOVQhsA6haZTp8qdNlgsGkOP9j6tz96nd3m+vZKghyy67r0gU9 +liA== 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=rGxecfoeO7J0ch1dgSDW11rX626ORhUGBzNvZWcGShA=; b=QVU/1Ifqqgqtak+lDWJqvKViODZCch7X+nthr2c/gLT4iHR58C1+nKGWgbpKGEq1CT A+chh7n4fJjWjiyJZf6evOKXRp+85mHoMKb1NMGAl5Ve546MVfISmja8G4BN9JMRzZ1o CWERlwTSWgQh06CAiOsoGgy+4HCXTw42d+koPxJj6m7britFz4YNeryeaUk+SqAEp7QZ avMZu6xdL2g1MsDYoZVsVr2o45UoRIO+CbIFWI8lfj6zhAVbPga3YSg+ZcfdWQg6cOlg xPcL3+WOTXgoKY0MbPUxSvMx38t7i28ULoRQjz/ZAE+rwraMYxa0fEY+FCaLxAIhDngJ EACQ== X-Gm-Message-State: AOAM532tYxw7Hq3rDiHHhRMibmjPOhJO4dtKoh3mT538VkIaep/WaLwR TGz3vFtxaiFI1e6rDg7DakxbXK6/k3bDAA== X-Google-Smtp-Source: ABdhPJzFQIXSI8iIRuTbcfW/bvqTKl99mfRENFqzmlh2hfHBBbD1sYZThWuJ4d/j2cFCB7wzTNLXRQ== X-Received: by 2002:a17:906:498b:: with SMTP id p11mr8669591eju.295.1622201435216; Fri, 28 May 2021 04:30:35 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:34 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Jack Wang , Gioh Kim Subject: [PATCHv3 for-next 18/20] RDMA/rtrs-srv: Fix memory leak when having multiple sessions Date: Fri, 28 May 2021 13:30:16 +0200 Message-Id: <20210528113018.52290-19-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang Gioh notice memory leak below unreferenced object 0xffff8880acda2000 (size 2048): comm "kworker/4:1", pid 77, jiffies 4295062871 (age 1270.730s) hex dump (first 32 bytes): 00 20 da ac 80 88 ff ff 00 20 da ac 80 88 ff ff . ....... ...... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000e85d85b5>] rtrs_srv_rdma_cm_handler+0x8e5/0xa90 [rtrs_server] [<00000000e31a988a>] cma_ib_req_handler+0xdc5/0x2b50 [rdma_cm] [<000000000eb02c5b>] cm_process_work+0x2d/0x100 [ib_cm] [<00000000e1650ca9>] cm_req_handler+0x11bc/0x1c40 [ib_cm] [<000000009c28818b>] cm_work_handler+0xe65/0x3cf2 [ib_cm] [<000000002b53eaa1>] process_one_work+0x4bc/0x980 [<00000000da3499fb>] worker_thread+0x78/0x5c0 [<00000000167127a4>] kthread+0x191/0x1e0 [<0000000060802104>] ret_from_fork+0x3a/0x50 unreferenced object 0xffff88806d595d90 (size 8): comm "kworker/4:1H", pid 131, jiffies 4295062972 (age 1269.720s) hex dump (first 8 bytes): 62 6c 61 00 6b 6b 6b a5 bla.kkk. backtrace: [<000000004447d253>] kstrdup+0x2e/0x60 [<0000000047259793>] kobject_set_name_vargs+0x2f/0xb0 [<00000000c2ee3bc8>] dev_set_name+0xab/0xe0 [<000000002b6bdfb1>] rtrs_srv_create_sess_files+0x260/0x290 [rtrs_server] [<0000000075d87bd7>] rtrs_srv_info_req_done+0x71b/0x960 [rtrs_server] [<00000000ccdf1bb5>] __ib_process_cq+0x94/0x100 [ib_core] [<00000000cbcb60cb>] ib_cq_poll_work+0x32/0xc0 [ib_core] [<000000002b53eaa1>] process_one_work+0x4bc/0x980 [<00000000da3499fb>] worker_thread+0x78/0x5c0 [<00000000167127a4>] kthread+0x191/0x1e0 [<0000000060802104>] ret_from_fork+0x3a/0x50 unreferenced object 0xffff88806d6bb100 (size 256): comm "kworker/4:1H", pid 131, jiffies 4295062972 (age 1269.720s) hex dump (first 32 bytes): 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... ff ff ff ff ff ff ff ff 00 59 4d 86 ff ff ff ff .........YM..... backtrace: [<00000000a18a11e4>] device_add+0x74d/0xa00 [<00000000a915b95f>] rtrs_srv_create_sess_files.cold+0x49/0x1fe [rtrs_server] [<0000000075d87bd7>] rtrs_srv_info_req_done+0x71b/0x960 [rtrs_server] [<00000000ccdf1bb5>] __ib_process_cq+0x94/0x100 [ib_core] [<00000000cbcb60cb>] ib_cq_poll_work+0x32/0xc0 [ib_core] [<000000002b53eaa1>] process_one_work+0x4bc/0x980 [<00000000da3499fb>] worker_thread+0x78/0x5c0 [<00000000167127a4>] kthread+0x191/0x1e0 [<0000000060802104>] ret_from_fork+0x3a/0x50 The problem is we increase device refcount by get_device in process_info_req for each path, but only does put_deice for last path, which lead to memory leak. To fix it, it also calls put_device when dev_ref is not 0. Fixes: e2853c49477d1 ("RDMA/rtrs-srv-sysfs: fix missing put_device") Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index a9288175fbb5..20efd44297fb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -208,6 +208,7 @@ rtrs_srv_destroy_once_sysfs_root_folders(struct rtrs_srv_sess *sess) device_del(&srv->dev); put_device(&srv->dev); } else { + put_device(&srv->dev); mutex_unlock(&srv->paths_mutex); } } From patchwork Fri May 28 11:30:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286789 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 43709C4708C for ; Fri, 28 May 2021 11:30:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2578D61378 for ; Fri, 28 May 2021 11:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234504AbhE1LcX (ORCPT ); Fri, 28 May 2021 07:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234665AbhE1LcM (ORCPT ); Fri, 28 May 2021 07:32:12 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911B9C061761 for ; Fri, 28 May 2021 04:30:37 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id df21so4478219edb.3 for ; Fri, 28 May 2021 04:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Waffu+p5UPYdv4TtYYnLf0EydpIp8rGvSwttG2VyGrM=; b=HMkGHQlA9r2T+aGhuE5i6cGPHu6tMf3C0MZQ5UkQk1EnuaAVysfCmCmU/s89p+BB6J KZdsGCUy/oSQ4LfE7sJKhX2u2D+1ltJclaIyamulqZYvJ4aJuuqwwOSf+12PhJBCoWx5 7MZscz3gC0IsriefYnZ9LoN79FN5DRLxHHVWKPLIec0DkINMAPKVoNyFTWDhpe38OaRE hW2gh8tlPLUTJiyLNvbooOllOaTPrf3fC5uYk5pimWEWQDMjW4htN3eSXbFDkBQlYeAP m6cK8Zbx9MS6ZGOPzO8Odfo5o7f4jT8JUznnTt1/ZV+fsj1CRtlSZNv4GVDxVPkNEbBB YbCg== 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=Waffu+p5UPYdv4TtYYnLf0EydpIp8rGvSwttG2VyGrM=; b=HXzwX8F8KRm2V09pGK0xR3QElOKX03Rd24CD6c3SfX+INcFIKzm7rPkkWa9FVsWmUp RESQk3YlkKzYmx3qj0B6s4jJvRtDR27Xjt7x/2eH8Bxf8sx7a0m8odVz8Q3ZVS4E037E I3egy2c7LfjbNOyKOcu+1H26jo+t8ocF/LPYRrjdj/bGD/1YFvDe5Kq6v9XUN3i3Ycad 2uzzWqRV/TktlhVRe8wBLOk1+M16fgOJc+EFnl1cg58Vutslkw/dpV4GWNgcGNDRciST EXAki3l5DQ15p0UIpsNhX0THARP7MPuTHDOd3pbS6h7tkj9pmgqakuY2JXfrGK2gj1bO zCbg== X-Gm-Message-State: AOAM531lsZbErTjM0QKm3Z6nP9t7IisWZy5nWJ63d97u776oCkAaBg/p YaFTioFEvASbgx0c1Gj6J01f+dLxRJSD6w== X-Google-Smtp-Source: ABdhPJxe5jnpF2ArvJ+M4yvIaONX/UXCmI9JqRaXe1mw05bC3UYB8FLEiogLWzDsTQNemz32jpdWbQ== X-Received: by 2002:aa7:c04e:: with SMTP id k14mr9117238edo.157.1622201436114; Fri, 28 May 2021 04:30:36 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:35 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Md Haris Iqbal , Gioh Kim Subject: [PATCHv3 for-next 19/20] RDMA/rtrs-clt: Check if the queue_depth has changed during a reconnection Date: Fri, 28 May 2021 13:30:17 +0200 Message-Id: <20210528113018.52290-20-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Md Haris Iqbal The queue_depth is a module parameter for rtrs_server. It is used on the client side to determing the queue_depth of the request queue for the RNBD virtual block device. During a reconnection event for an already mapped device, in case the rtrs_server module queue_depth has changed, fail the reconnect attempt. Also stop further auto reconnection attempts. A manual reconnect via sysfs has to be triggerred. Fixes: 6a98d71daea18 ("RDMA/rtrs: client: main functionality") Signed-off-by: Md Haris Iqbal Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 88a1c93f244a..e4a23c40d4c7 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1780,7 +1780,19 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con, queue_depth); return -ECONNRESET; } - if (!sess->rbufs || sess->queue_depth < queue_depth) { + if (sess->queue_depth > 0 && queue_depth != sess->queue_depth) { + rtrs_err(clt, "Error: queue depth changed\n"); + + /* + * Stop any more reconnection attempts + */ + sess->reconnect_attempts = -1; + rtrs_err(clt, + "Disabling auto-reconnect. Trigger a manual reconnect after issue is resolved\n"); + return -ECONNRESET; + } + + if (!sess->rbufs) { kfree(sess->rbufs); sess->rbufs = kcalloc(queue_depth, sizeof(*sess->rbufs), GFP_KERNEL); @@ -1794,7 +1806,7 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con, sess->chunk_size = sess->max_io_size + sess->max_hdr_size; /* - * Global queue depth and IO size is always a minimum. + * Global IO size is always a minimum. * If while a reconnection server sends us a value a bit * higher - client does not care and uses cached minimum. * @@ -1802,8 +1814,7 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con, * connections in parallel, use lock. */ mutex_lock(&clt->paths_mutex); - clt->queue_depth = min_not_zero(sess->queue_depth, - clt->queue_depth); + clt->queue_depth = sess->queue_depth; clt->max_io_size = min_not_zero(sess->max_io_size, clt->max_io_size); mutex_unlock(&clt->paths_mutex); From patchwork Fri May 28 11:30:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 12286791 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 8D107C4708D for ; Fri, 28 May 2021 11:30:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7170461378 for ; Fri, 28 May 2021 11:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234665AbhE1LcZ (ORCPT ); Fri, 28 May 2021 07:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233711AbhE1LcN (ORCPT ); Fri, 28 May 2021 07:32:13 -0400 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 7DF20C061763 for ; Fri, 28 May 2021 04:30:38 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id gb17so4815145ejc.8 for ; Fri, 28 May 2021 04:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wf/xwTk8dJcDxIyKJjIrWlgy2XpHIkaxNy3ZNk6imnM=; b=IvGXNZLCz27ydYzSo891kzVs80DcluELdSD42ctJmMdwPXg5avxILjjuke4tMaewhd PqueOhQYc3dr/9tKuLszFtwKl5J/G0qC6lRwTLM88g06Xj4/nw4l2g3TieCGPJXjAJMy sx/j6fh0J+ylngs96Hw/OGA51gw86nVZVzEG00oamzPeyTclR9EBmcCyO2xOSBUKI0HE V04pbHp0QvgNfCMbCmq08TGwKXZM+Wea2spGby9vti7oV1Ll2CUrKCt4vOGphQqC2X2C TqJRkI5lnhWvYulJENBM2KMSZCwHG3UvF1fXYCmdYcMLUhK4U5torOTRKGTttWQzo6BK 2XwA== 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=Wf/xwTk8dJcDxIyKJjIrWlgy2XpHIkaxNy3ZNk6imnM=; b=mKlMehpCcrzeetw+Myf23j3dxbkjfkveL1GzaEeRUVddJArY1/uXBZTdzBjJcivNT2 +KlmB2wEI9+5k4XPebz7mVkr5mBFH/28g5KTuat0PuLkZYZTMtBra4ngvg1tzjFVA1il jcc+yI3v3MLsdXTiwBLFogKbnfdxaz108ueiS4sr9VhzUIrLyVDYRVPJjk89V+Lc57Gk j+Zop5UcRaIHmavHVlw9Yd23k2HtFQkRfAKK72cI651ZXEf4p05KzWLxk5gGcyFjjngp wKzQZuA+lMcwb+ofGasEV3YR+BkWOsVnmxPko+z3TGRXQnUP0MZ48IYsmq6O/rYnH6eD tXWA== X-Gm-Message-State: AOAM531RftL+USlEMfMlxRqemR+NUyKqqvQIRSKpG/k8fYb3PsYDzWWR o1S8qJF77w3dnGBC/mMuYwmUqXERmRRyRw== X-Google-Smtp-Source: ABdhPJw8Vmig8BvnJ1FhTY4+W9XCndQl9qnaxdGF5R4S1axXFN1vKJJOfAelsJdWgZwYhTMbsc0xZw== X-Received: by 2002:a17:907:1117:: with SMTP id qu23mr285228ejb.71.1622201436974; Fri, 28 May 2021 04:30:36 -0700 (PDT) Received: from jwang-Latitude-5491.fkb.profitbricks.net ([2001:16b8:497d:7d00:983b:122a:4685:3849]) by smtp.gmail.com with ESMTPSA id p15sm2594578edr.50.2021.05.28.04.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 04:30:36 -0700 (PDT) From: Jack Wang To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Gioh Kim Subject: [PATCHv3 for-next 20/20] RDMA/rtrs-clt: Fix memory leak of not-freed sess->stats and stats->pcpu_stats Date: Fri, 28 May 2021 13:30:18 +0200 Message-Id: <20210528113018.52290-21-jinpu.wang@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528113018.52290-1-jinpu.wang@ionos.com> References: <20210528113018.52290-1-jinpu.wang@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Gioh Kim sess->stats and sess->stats->pcpu_stats objects are freed when sysfs entry is removed. If something wrong happens and session is closed before sysfs entry is created, sess->stats and sess->stats->pcpu_stats objects are not freed. This patch adds freeing of them at three places: 1. When client uses wrong address and session creation fails. 2. When client fails to create a sysfs entry. 3. When client adds wrong address via sysfs add_path. Fixes: 215378b838df0 ("RDMA/rtrs: client: sysfs interface functions") Signed-off-by: Gioh Kim Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index e4a23c40d4c7..8e05a71d8da1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2765,6 +2765,8 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, if (err) { list_del_rcu(&sess->s.entry); rtrs_clt_close_conns(sess, true); + free_percpu(sess->stats->pcpu_stats); + kfree(sess->stats); free_sess(sess); goto close_all_sess; } @@ -2773,6 +2775,8 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, if (err) { list_del_rcu(&sess->s.entry); rtrs_clt_close_conns(sess, true); + free_percpu(sess->stats->pcpu_stats); + kfree(sess->stats); free_sess(sess); goto close_all_sess; } @@ -3048,6 +3052,8 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, close_sess: rtrs_clt_remove_path_from_arr(sess); rtrs_clt_close_conns(sess, true); + free_percpu(sess->stats->pcpu_stats); + kfree(sess->stats); free_sess(sess); return err;