From: Joel Granados <j.granados@samsung.com>
To: Keith Busch <kbusch@kernel.org>
Cc: <sagi@grimberg.me>, <hch@lst.de>,
<linux-nvme@lists.infradead.org>, <gost.dev@samsung.com>,
<joshi.k@samsung.com>, <javier.gonz@samsung.com>,
<p.raghav@samsung.com>
Subject: Re: [RFC 1/3] nvme: Return -ENOMEM when kzalloc fails
Date: Fri, 28 Oct 2022 11:07:25 +0200 [thread overview]
Message-ID: <20221028090725.4qhcfdgzxpm56sew@localhost> (raw)
In-Reply-To: <Y1qxUXuqDHYi+LO+@kbusch-mbp.dhcp.thefacebook.com>
[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]
On Thu, Oct 27, 2022 at 10:26:57AM -0600, Keith Busch wrote:
> On Thu, Oct 27, 2022 at 05:57:22PM +0200, Joel Granados wrote:
> > In nvme_init_non_mdts_limits function we were returning 0 when kzalloc
> > failed. This patch corrects this behavior and return -ENOMEM
> > Fixes: 5befc7c26e5a ("nvme: implement non-mdts command limits")
>
> I'm pretty sure I had this returning 0 on purpose. We can proceed
> without this optional structure.
Looking a bit more into this I see a couple of things:
1. If we fail in the kzalloc, ctrl->max_discard_segments and
ctrl->max_zeroes_sectors do not get set but we return 0. On the other
hand if nvme_submit_sync_cmd fails, ctrl->max_discard_segments and
ctrl->max_zeroes_sectors still do not get set but we forward
nvme_submit_sync_cmd's error code.
* Shouldn't we just set ret to 0 before returning regardless of what
happens in nvme_submit_sync_cmd?
* If we are returning 0 no matter what, shouldn't this function be
void?
2. The function nvme_scan_work will not rescan the controler if
nvme_init_non_mdts_limits has a return value that is less than zero.
* Should we remove the check in nvme_scan_work to let the scan move
forward regardless of the return value from
nvme_init_non_mdts_limits?
3. I think what makes more sense is to:
a. Make nvme_init_non_mdts_limits a void function
b. Move the warning of failing to read mdts limits inside
nvme_init_non_mdts_limits
c. Allow the scan work to move forward after executing
nvme_init_non_mdts_limits
What do you think? I can spin up a patch for this if it makes sense.
Best
Joel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2022-10-28 9:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20221027160102eucas1p1bb39a9a2b8ed6b54f854849532359332@eucas1p1.samsung.com>
2022-10-27 15:57 ` [RFC 0/3] nvme : Add ioctl to query nvme device attributes Joel Granados
[not found] ` <CGME20221027160108eucas1p223383fc27ba0a27a38f7b768c562a1ed@eucas1p2.samsung.com>
2022-10-27 15:57 ` [RFC 1/3] nvme: Return -ENOMEM when kzalloc fails Joel Granados
2022-10-27 16:26 ` Keith Busch
2022-10-28 9:07 ` Joel Granados [this message]
2022-10-30 8:02 ` Christoph Hellwig
2022-10-31 12:36 ` Joel Granados
[not found] ` <CGME20221027160108eucas1p1cc1351fd8bf35ef6e5220e0cdc865ff4@eucas1p1.samsung.com>
2022-10-27 15:57 ` [RFC 2/3] nvme: Move nvme identify CS to separate function Joel Granados
[not found] ` <CGME20221027160108eucas1p2722b30a1be27a855e2b0f2495fed15ab@eucas1p2.samsung.com>
2022-10-27 15:57 ` [RFC 3/3] nvme : Add ioctl to query nvme attributes Joel Granados
2022-10-27 16:55 ` Keith Busch
2022-10-28 10:38 ` Joel Granados
2022-10-28 14:52 ` Keith Busch
2022-10-28 15:52 ` Joel Granados
2022-10-28 16:22 ` Keith Busch
2022-10-31 12:24 ` Joel Granados
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=20221028090725.4qhcfdgzxpm56sew@localhost \
--to=j.granados@samsung.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=javier.gonz@samsung.com \
--cc=joshi.k@samsung.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=p.raghav@samsung.com \
--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;
as well as URLs for NNTP newsgroup(s).