Re: [PATCH v7 06/25] RDMA/rtrs: client: main functionality

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

 



On Thu, Jan 16, 2020 at 05:24:16PM +0100, Jinpu Wang wrote:
> On Thu, Jan 16, 2020 at 4:58 PM Leon Romanovsky <leon@xxxxxxxxxx> 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 <leon@xxxxxxxxxx> wrote:
> > > >
> > > > On Thu, Jan 16, 2020 at 01:58:56PM +0100, Jack Wang wrote:
> > > > > From: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx>
> > > > >
> > > > > 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 <danil.kipnis@xxxxxxxxxxxxxxx>
> > > > > Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx>
> > > > > ---
> > > > >  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 <linux/module.h>
> > > > > +#include <linux/rculist.h>
> > > > > +#include <linux/blkdev.h> /* 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

If you so in favor of switch inside switch, at lest do it properly.

The scsi_device_set_state() function implements success-oriented
approach and has very clear state machine without distraction and
extra variables like changed/not_changed. You have completely
opposite implementation to scsi_device_set_state().

Thanks

>
> Thanks



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

  Powered by Linux