Re: [RFC PATCH net] net/smc: Reset conn->lgr when link group registration fails

Wen Gu
2021-12-30T03:50:31Z

Thanks for your reply.

On 2021/12/29 9:07 pm, Karsten Graul wrote:
> On 28/12/2021 08:49, Wen Gu wrote:
>> SMC connections might fail to be registered to a link group due to
>> things like unable to find a link to assign to in its creation. As
>> a result, connection creation will return a failure and most
>> resources related to the connection won't be applied or initialized,
>> such as conn->abort_work or conn->lnk.
>
> I agree with your fix to set conn->lgr to NULL when smc_lgr_register_conn() fails.
>
> It would probably be better to have smc_lgr_register_conn() set conn->lgr instead to set
> it before in smc_conn_create(). So it would not be set at all then the registration failes.
>

I agree and will improve it, thanks.

>
> What I do not understand is the extra step after the new label out_unreg: that
> may invoke smc_lgr_schedule_free_work(). You did not talk about that one.
> Is the idea to have a new link group get freed() when a connection could not
> be registered on it?

I noticed that smc_conn_create() may be invoked by smc_listen_work(rdma/ism) and
__smc_connect(rdma/ism).

In smc_listen_work() case, if smc_conn_create() fails at smc_lgr_register_conn()
and returns a not-zero rc, the conn->lgr (which won't be reset in original
implementation) will be freed through smc_listen_decline()->smc_conn_abort()->
smc_conn_free()->smc_lgr_schedule_free_work().

So I invoke smc_lgr_schedule_free_work() in label 'out_unreg:' to be consistent
with the above behavior because the conn->lgr is reset to NULL in my implementation,
thus smc_lgr_schedule_free_work() won't be invoked in smc_conn_free().

In __smc_connect() case, I noticed that the behavior of __smc_connect() is not
symmetric with smc_listen_work()'s. If smc_conn_create() fails at smc_lgr_register_conn()
__smc_connect() will not try to free conn->lgr as what did in smc_listen_work().
I am a bit puzzled about it and want to hear your opinions.

In my humble opinion, it also should try to free link group in __smc_connect() case,
so I invoke smc_lgr_schedule_free_work() in label 'out_unreg:'.

> In that case I would expect this code after label create:
> in smc_lgr_create(), when the rc from smc_lgr_register_conn() is not zero.
> Thoughts?

Maybe we should try to free the link group when the registration fails, no matter
it is new created or already existing? If so, is it better to do it in the same
place like label 'out_unreg'?

Cheers,
Wen Gu