RE: [Patch v5 08/21] CIFS: SMBD: Upper layer reconnects to SMB Direct session

From: Matthew Wilcox
Date: Wed Nov 01 2017 - 15:44:52 EST


From: Pavel Shilovsky [mailto:piastryyy@xxxxxxxxx]
> 2017-10-18 16:09 GMT-07:00 Long Li <longli@xxxxxxxxxxxxxxxxxxxxxx>:
> > From: Long Li <longli@xxxxxxxxxxxxx>
> >
> > Do a reconnect on SMB Direct when it is used as the connection. Reconnect
> can
> > happen for many reasons and it's mostly the decision of SMB2 upper layer.
> >
> > Signed-off-by: Long Li <longli@xxxxxxxxxxxxx>
> > ---
> > fs/cifs/connect.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 2c0b34a..8ca3c13 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -406,7 +406,14 @@ cifs_reconnect(struct TCP_Server_Info *server)
> >
> > /* we should try only the port we connected to before */
> > mutex_lock(&server->srv_mutex);
> > +#ifdef CONFIG_CIFS_SMB_DIRECT
> > + if (server->rdma)
> > + rc = smbd_reconnect(server);
> > + else
> > + rc = generic_ip_connect(server);
>
> Minor: here and in other similar places we can remove #else part below
> and put #endif before else block above.
>
> > +#else
> > rc = generic_ip_connect(server);
> > +#endif

I'd suggest rather:

#ifdef CONFIG_CIFS_SMB_DIRECT
#define cifs_rdma_enabled(server) ((server)->rdma)
#else
#define cifs_rdma_enabled(server) 0
#endif

Then we don't need an ifdef in the users, just:

if (cifs_rdma_enabled(server))
rc = smbd_reconnect(server);
else
rc = generic_ip_connect(server);