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 3/3] nvme : Add ioctl to query nvme attributes
Date: Mon, 31 Oct 2022 13:24:20 +0100 [thread overview]
Message-ID: <20221031122420.t7u6o73g2bjltot5@localhost> (raw)
In-Reply-To: <Y1wByyGo6FS/6hmd@kbusch-mbp.dhcp.thefacebook.com>
[-- Attachment #1: Type: text/plain, Size: 2339 bytes --]
On Fri, Oct 28, 2022 at 10:22:35AM -0600, Keith Busch wrote:
> On Fri, Oct 28, 2022 at 05:52:30PM +0200, Joel Granados wrote:
> > On Fri, Oct 28, 2022 at 08:52:01AM -0600, Keith Busch wrote:
> > > On Fri, Oct 28, 2022 at 12:38:27PM +0200, Joel Granados wrote:
> > > > 3. And the variables that are not in struct nvme_ctrl. Here, we have not
> > > > option but to make an IO.
> > >
> > > You do have another option: we have historically added new fields to
> > > nvme_ctrl to cache parameters that are repeatedly referenced in other
> > > contexts, and this usage appears to qualify.
> >
> > Agreed. That is yet another option. Will do that for my V1.
> > Thx for the feedback
>
> Just for the record, I don't really like this approach, but I don't have
> a better suggestion right now other than opening up the admin queue or
> exporting a ton of sysfs attributes (and each carry a different set of
> concerns..).
>
> My concern here is that drives implementing new specs may have new
> constraints that applications need to know, but older kernels won't
> accomodate. You are handling this by error'ing out the query, so it
> relies on the application implementing a sane fallback (assuming such a
> fallback for future attributes even exists). This just does not feel
> very future-proof.
There might be an additional route to handle the case where the user has
new kernel headers and is running the ioctl on an older kernel: We can
use copy_struct_from_user f5a1a536fa14 ("lib: introduce
copy_struct_from_user() helper").
In summary it has a clear behavior/assumptions for the three possible
cases:
1. When kernel and user space have the same header version it just
copies the struct.
2. When the kernel has a higher version of the struct, it only copies
what the user space requested in argsz.
3. When user has an old kernel (The case that you are worried about) it
will only fill up the members that the kernel knows about provided
that members that are not contained in the kernel struct are zeroed
out.
What do you think?
I did not implement this at the outset because I was wanting to avoid
the additional call to copy_struct_from_user. But if this provides a
suitable solution for you case, then it is trivial to include it in the
patch.
Best
Joel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
prev parent reply other threads:[~2022-10-31 12:25 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
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
2022-10-30 8:02 ` Christoph Hellwig
2022-10-31 12:36 ` Joel Granados
2022-10-27 15:57 ` [RFC 2/3] nvme: Move nvme identify CS to separate function Joel Granados
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 [this message]
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=20221031122420.t7u6o73g2bjltot5@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