From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 41303C33CB6 for ; Thu, 16 Jan 2020 16:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15BE92077C for ; Thu, 16 Jan 2020 16:24:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="PyLaSZFm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726872AbgAPQY2 (ORCPT ); Thu, 16 Jan 2020 11:24:28 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:43448 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbgAPQY2 (ORCPT ); Thu, 16 Jan 2020 11:24:28 -0500 Received: by mail-io1-f68.google.com with SMTP id n21so22458181ioo.10 for ; Thu, 16 Jan 2020 08:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=apIz2+9yoUfuStq5UMu8JP8acA1lx+rNR0oTEq6+/+s=; b=PyLaSZFmKclzKXc2mofAeRISHMo3IWIZvYOyzXjwWgiLonnaYcHRnYY5Svxx66yr7f jLGOtmtEc53zsMlgG6EdXnP4HHgPAhPlGnNFM8X3Y0V+pcglmBH8kHbl+hSAHmN8gUD2 H9FpdGXns3IiBm3bbIpeGscEvRwjhxG67Z9nHKF08lQF0ljI6NviuoRo+fmTUOu+ALa1 FE6W2xv4JWmwA1MJswmHEBnY3KIAo6mAnSdC0eTvFoFw8ltYmc+0W4percxA0OQUEYg1 XLbIO803hHOeZbjtYia3DefqH70LdH5+s3ihhmc0NF0nTdJbwxybtvvXP5/+CljjgUhR O2Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=apIz2+9yoUfuStq5UMu8JP8acA1lx+rNR0oTEq6+/+s=; b=YVEbu339SSWu50VOg3zT8TWNtRAqjGzMqvIWCCHxo+oPf1nayZlL3L/JZCCJV6hcuB Ga2P4IZE0uxkUTfxoZhBuExWOMYDtUPAkl3pgiiHgc4zWmQMadwG1qkNecrfF0zYqHQV dDuPZH19s1iULX/9E2T05ddoTghbVl22CaJPNwS4lA4LDo4DOFukKNWwEreSQ9RIwsZW mSJnCCHLSetjdrdcd6LqDOGCrzeSWSj0V+dhTC+uHOzqM6TQGy4/wQbniSwfbG28GV7Q PTWDMaiwLLEBEYQgBjFOMFCHAW0TLsrpbwHemFzIJPHegCjGzvmPzrDiAFTtQ55FqUT4 eIaw== X-Gm-Message-State: APjAAAXnw8DW1M37ZqqAyDJ5nXeINtbT7ev7SY8yrB7if9K1nvHItKSn IN2wmW7CONuzD6w1ysgWqckC7Oe4hxnrrq7eavxYXQ== X-Google-Smtp-Source: APXvYqwEbz/nPKl0Ju6yl68j4LvWHYZBTDI1g6S3NJ2/g8vGUHJa7Caj1TYzBMwRrxOdVH7Rk3i+WPh3WyrLmfJlF2Y= X-Received: by 2002:a02:ca10:: with SMTP id i16mr30169945jak.10.1579191867085; Thu, 16 Jan 2020 08:24:27 -0800 (PST) MIME-Version: 1.0 References: <20200116125915.14815-1-jinpuwang@gmail.com> <20200116125915.14815-7-jinpuwang@gmail.com> <20200116145300.GC12433@unreal> <20200116155800.GA18467@unreal> In-Reply-To: <20200116155800.GA18467@unreal> From: Jinpu Wang Date: Thu, 16 Jan 2020 17:24:16 +0100 Message-ID: Subject: Re: [PATCH v7 06/25] RDMA/rtrs: client: main functionality To: Leon Romanovsky Cc: Jack Wang , linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, Jens Axboe , Christoph Hellwig , Sagi Grimberg , Bart Van Assche , Doug Ledford , Jason Gunthorpe , Danil Kipnis , Roman Penyaev Content-Type: text/plain; charset="UTF-8" Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, Jan 16, 2020 at 4:58 PM Leon Romanovsky wrote: > > On Thu, Jan 16, 2020 at 04:43:41PM +0100, Jinpu Wang wrote: > > On Thu, Jan 16, 2020 at 3:53 PM Leon Romanovsky wrote: > > > > > > On Thu, Jan 16, 2020 at 01:58:56PM +0100, Jack Wang wrote: > > > > From: Jack Wang > > > > > > > > This is main functionality of rtrs-client module, which manages > > > > set of RDMA connections for each rtrs session, does multipathing, > > > > load balancing and failover of RDMA requests. > > > > > > > > Signed-off-by: Danil Kipnis > > > > Signed-off-by: Jack Wang > > > > --- > > > > drivers/infiniband/ulp/rtrs/rtrs-clt.c | 2967 ++++++++++++++++++++++++ > > > > 1 file changed, 2967 insertions(+) > > > > create mode 100644 drivers/infiniband/ulp/rtrs/rtrs-clt.c > > > > > > > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c > > > > new file mode 100644 > > > > index 000000000000..717d19d4d930 > > > > --- /dev/null > > > > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c > > > > @@ -0,0 +1,2967 @@ > > > > +// SPDX-License-Identifier: GPL-2.0-or-later > > > > +/* > > > > + * RDMA Transport Layer > > > > + * > > > > + * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved. > > > > + * > > > > + * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. > > > > + * > > > > + * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved. > > > > > > Please no extra lines between Copyright lines. > > I checked in kernel tree, seems most of Copyright indeed contain no > > extra line in between > > > > > > > > > + */ > > > > + > > > > +#undef pr_fmt > > > > +#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt > > > > > > I never understood this pr_fmt() thing, do we really need it? > > you can custorm the format for print, include modue name and line > > number in this case, it's quite useful for debugging. > > The idea that messages are needed to be unique and don't rely on line > numbers. Then you have to check all other message in order to be unique, that is too much :) > > > > > > > > + > > > > +#include > > > > +#include > > > > +#include /* for BLK_MAX_SEGMENT_SIZE */ > > > > + > > > > +#include "rtrs-clt.h" > > > > +#include "rtrs-log.h" > > > > + > > > > +#define RTRS_CONNECT_TIMEOUT_MS 30000 > > > > + > > > > +MODULE_DESCRIPTION("RDMA Transport Client"); > > > > +MODULE_LICENSE("GPL"); > > > > + > > > > +static ushort nr_cons_per_session; > > > > +module_param(nr_cons_per_session, ushort, 0444); > > > > +MODULE_PARM_DESC(nr_cons_per_session, > > > > + "Number of connections per session. (default: nr_cpu_ids)"); > > > > + > > > > +static int retry_cnt = 7; > > > > +module_param_named(retry_cnt, retry_cnt, int, 0644); > > > > +MODULE_PARM_DESC(retry_cnt, > > > > + "Number of times to send the message if the remote side didn't respond with Ack or Nack (default: 7, min: " > > > > + __stringify(MIN_RTR_CNT) ", max: " > > > > + __stringify(MAX_RTR_CNT) ")"); > > > > + > > > > +static int __read_mostly noreg_cnt; > > > > +module_param_named(noreg_cnt, noreg_cnt, int, 0444); > > > > +MODULE_PARM_DESC(noreg_cnt, > > > > + "Max number of SG entries when MR registration does not happen (default: 0)"); > > > > > > We don't like modules in new code. > > could you elaberate a bit, no module paramters? which one? all? > > All of them. Ok snip > > > > +static bool __rtrs_clt_change_state(struct rtrs_clt_sess *sess, > > > > + enum rtrs_clt_state new_state) > > > > +{ > > > > + enum rtrs_clt_state old_state; > > > > + bool changed = false; > > > > + > > > > + lockdep_assert_held(&sess->state_wq.lock); > > > > + > > > > + old_state = sess->state; > > > > + switch (new_state) { > > > > + case RTRS_CLT_CONNECTING: > > > > + switch (old_state) { > > > > > > Double switch is better to be avoided. > > what's the better way to do it? > > Rewrite function to be more readable. Frankly I think it's easy to read, depends on old_state change to new state. see also scsi_device_set_state Thanks