public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Honggang LI <honli@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	Leon Romanovsky <leonro@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/srpt: Fix TPG creation
Date: Wed, 23 Oct 2019 21:01:40 -0700	[thread overview]
Message-ID: <f01ed6c8-b499-85d3-1b8e-d0b2350e44d3@acm.org> (raw)
In-Reply-To: <20191024033715.GA16157@dhcp-128-227.nay.redhat.com>

On 2019-10-23 20:37, Honggang LI wrote:
> On Wed, Oct 23, 2019 at 01:41:06PM -0700, Bart Van Assche wrote:
>> +	mutex_lock(&sport->port_gid_id.mutex);
>> +	list_for_each_entry(stpg, &sport->port_gid_id.tpg_list, entry) {
>> +		if (!IS_ERR_OR_NULL(ch->sess))
>                 ^^^^^^^
>> +			break;
>> +		ch->sess = target_setup_session(&stpg->tpg, tag_num,
>                            ^^^^^^^^^^^^^^^^^^^^
>>  					tag_size, TARGET_PROT_NORMAL, i_port_id,
>>  					ch, NULL);
>> -	/* Retry without leading "0x" */
>> -	if (sport->port_gid_id.tpg.se_tpg_wwn && IS_ERR_OR_NULL(ch->sess))
>> -		ch->sess = target_setup_session(&sport->port_gid_id.tpg, tag_num,
>> +		if (!IS_ERR_OR_NULL(ch->sess))
>                     ^
>> +			break;
> 
> I'm confused about this 'if' statement. In case you repeated the
> validation as previous 'if' statement, it is redundance.
> 
> In case you check the return of the first target_setup_session,
> it seems wrong, we only need to retry in case first target_setup_session
> was failed. But you break out, and skip the second target_setup_session.
> 
>> +		/* Retry without leading "0x" */
>> +		ch->sess = target_setup_session(&stpg->tpg, tag_num,
>                            ^^^^^^^^^^^^^^^^^^^^
>>  						tag_size, TARGET_PROT_NORMAL,
>>  						i_port_id + 2, ch, NULL);

Hi Honggang,

The purpose of this code is to keep iterating until a session has been
created. The "if (!IS_ERR_OR_NULL(ch->sess)) break" code prevents
further target_setup_session() calls after a session has been created
successfully.

Bart.

  reply	other threads:[~2019-10-24  4:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 20:41 [PATCH] RDMA/srpt: Fix TPG creation Bart Van Assche
2019-10-24  3:37 ` Honggang LI
2019-10-24  4:01   ` Bart Van Assche [this message]
2019-10-24 13:07 ` Honggang LI
2019-10-28 16:32 ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f01ed6c8-b499-85d3-1b8e-d0b2350e44d3@acm.org \
    --to=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=honli@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox