public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Cc: "kbusch@kernel.org" <kbusch@kernel.org>,
	"hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me>
Subject: Re: [PATCH] nvme-fabrics: open code __nvmf_host_find()
Date: Mon, 5 Jun 2023 13:51:36 +0300	[thread overview]
Message-ID: <da92cc34-e327-d324-0ff8-5db2d5c2b707@nvidia.com> (raw)
In-Reply-To: <4b0ddae0-bc01-34ad-9ab4-4d63e262ae3f@nvidia.com>



On 05/06/2023 12:13, Chaitanya Kulkarni wrote:
> On 6/3/23 17:35, Max Gurtovoy wrote:
>> Hi,
>>
>> On 02/06/2023 9:47, Chaitanya Kulkarni wrote:
>>> There is no point in maintaining a separate funciton __nvmf_host_find()
>>
>> typo *function
>>
>>> that has only one caller nvmf_host_add() especially when caller and
>>> callee both are small enough to merge.
>>>
>>> Due to this we are actually repeating the error handling code in both
>>> callee and caller for no reason that can be avoided, but instead we have
>>> to read both function to establish the correctness along with additional
>>> lockdep warning check due to involved locking.
>>>
>>> Just open code __nvmf_host_find() in nvme_host_alloc() with appropriate
>>> comment that removes repeated error checks in the callee/caller and
>>> lockdep check that is needed for the nvmf_hosts_mutex involvement,
>>> diffstats :-
>>
>> The above 2 sentences are redundant IMO.
>> There is no error handling in the callee so it can't be repeated. We
>> just return error in the callee.
> 
> and that is error handling, without error conditions we would
> only returning either valid host (that is non NULL) or NULL in
> absence of host in the list. That -EINVAL return is the reason
> we need separate check with IS_ERR in the caller ...
> 
> -    if (IS_ERR(host)) {
> -        goto out_unlock;
> -    } else if (host) {
> -        kref_get(&host->ref);
> -        goto out_unlock;

this check happens in the caller. No duplication.

> 
>> The first sentence is good enough to justify this patch.
>>
>> Lets have instead:
>>
>> "Merge its code with the only caller nvmf_host_add() since both are
>> small enough.
>> The lockdep check in __nvmf_host_find() after the merge becomes
>> redundant so we can remove it too."
>>
>>
> 
> I don't understand what you are saying, provide a complete commit
> log that can be applied verbatim to this patch.

just say something like:

"
Open code __nvmf_host_find() since there is only one caller for it and 
both are small enough to merge.
As a result, the lockdep check in __nvmf_host_find() after the merge 
becomes redundant so we can remove it too.
"


> 
> -ck
> 
> 


  reply	other threads:[~2023-06-05 10:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02  6:47 [PATCH] nvme-fabrics: open code __nvmf_host_find() Chaitanya Kulkarni
2023-06-02 15:04 ` Christoph Hellwig
2023-06-04  0:35 ` Max Gurtovoy
2023-06-05  9:13   ` Chaitanya Kulkarni
2023-06-05 10:51     ` Max Gurtovoy [this message]
2023-06-05 21:52 ` Sagi Grimberg
2023-06-09 15:46 ` Keith Busch

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=da92cc34-e327-d324-0ff8-5db2d5c2b707@nvidia.com \
    --to=mgurtovoy@nvidia.com \
    --cc=chaitanyak@nvidia.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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