* Question about ioctl interface - IO passthru
@ 2019-01-31 13:59 Eyal BenDavid
0 siblings, 0 replies; 6+ messages in thread
From: Eyal BenDavid @ 2019-01-31 13:59 UTC (permalink / raw)
Hi,
I wrote a small program to perform IOs based on the ioctl interface
from linux_ioctl.h and code from nvme-cli.
Specifically
^ permalink raw reply [flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
@ 2019-01-31 14:09 Eyal BenDavid
2019-01-31 14:55 ` Keith Busch
0 siblings, 1 reply; 6+ messages in thread
From: Eyal BenDavid @ 2019-01-31 14:09 UTC (permalink / raw)
Hi,
I wrote a small program to perform IOs based on the ioctl interface
from linux_ioctl.h and code from nvme-cli.
Specifically I wrote this function for write zero (code is used in
stress and verification testing).
Note that this is C++ (only difference is the default values for
function arguments)
====
int nvme_io_passthru(int fd,
uint32_t nsid,
uint8_t opcode,
uint64_t slba,
uint16_t nblocks,
void* data = NULL,
uint32_t dlen = 0,
uint8_t flags = 0,
uint32_t timeout = 30000,
uint16_t control = 0,
uint32_t reftag = 0,
uint16_t apptag = 0,
uint16_t appmask = 0)
{
struct nvme_passthru_cmd cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.opcode = opcode;
cmd.flags = flags;
cmd.nsid = nsid;
cmd.addr = (uint64_t)(uintptr_t) data;
cmd.data_len = dlen;
cmd.cdw10 = (slba & 0xffffffff);
cmd.cdw11 = (slba >> 32);
cmd.cdw12 = (nblocks | (control << 16));
cmd.cdw14 = reftag;
cmd.cdw15 = (apptag | (appmask << 16));
cmd.timeout_ms = timeout;
return ioctl(fd, NVME_IOCTL_IO_CMD, &cmd);
}
====
To my surprise the function worked fine not only with write zero but
with other IO opcodes (read, write, compare)
The advantage is now I control the timeout value in IO commands!
What is the difference from using "nvme_user_io" structure?
Is it safe to use this version of IO commands?
Thanks!
Eyal BD.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
2019-01-31 14:09 Question about ioctl interface - IO passthru Eyal BenDavid
@ 2019-01-31 14:55 ` Keith Busch
2019-01-31 18:08 ` Eyal BenDavid
0 siblings, 1 reply; 6+ messages in thread
From: Keith Busch @ 2019-01-31 14:55 UTC (permalink / raw)
On Thu, Jan 31, 2019@04:09:18PM +0200, Eyal BenDavid wrote:
> What is the difference from using "nvme_user_io" structure?
> Is it safe to use this version of IO commands?
The passthru structure is good to use for any command. The
nvme_user_io structure is a legacy feature from very early nvme days
when read/write/compare were the only IO commands. It didn't extend to
other IO commands, and deprecating it wouldn't be a bad thing.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
2019-01-31 14:55 ` Keith Busch
@ 2019-01-31 18:08 ` Eyal BenDavid
2019-01-31 18:39 ` Chaitanya Kulkarni
0 siblings, 1 reply; 6+ messages in thread
From: Eyal BenDavid @ 2019-01-31 18:08 UTC (permalink / raw)
On Thu, Jan 31, 2019@4:56 PM Keith Busch <keith.busch@intel.com> wrote:
>
> On Thu, Jan 31, 2019@04:09:18PM +0200, Eyal BenDavid wrote:
> > What is the difference from using "nvme_user_io" structure?
> > Is it safe to use this version of IO commands?
>
> The passthru structure is good to use for any command. The
> nvme_user_io structure is a legacy feature from very early nvme days
> when read/write/compare were the only IO commands. It didn't extend to
> other IO commands, and deprecating it wouldn't be a bad thing.
Thanks!
A good start is to rewrite nvme read/write/compare commands using the
passthru structure instead of nvme_user_io.
---
Eyal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
2019-01-31 18:08 ` Eyal BenDavid
@ 2019-01-31 18:39 ` Chaitanya Kulkarni
2019-01-31 19:05 ` Keith Busch
0 siblings, 1 reply; 6+ messages in thread
From: Chaitanya Kulkarni @ 2019-01-31 18:39 UTC (permalink / raw)
One of the issue with the current nvme_user_io structure is that the new commands
such as NVMe Zone append?which returns result will not be able to use the nvme_user_io
since it lacks?that field (e.g. result field) and had to use the passthru?command or add a new
command definition.
So I think it is a good start that to use the nvme_passthru command and make it more generic.
Keith any comments on this ?
or should we extend the nvme_user_io command with
the new addition such as result field (less likely in my?opinion, may break IOCTL)??
From: Linux-nvme <linux-nvme-bounces@lists.infradead.org> on behalf of Eyal BenDavid <bdeyal@gmail.com>
Sent: Thursday, January 31, 2019 10:08 AM
To: Keith Busch
Cc: linux-nvme
Subject: Re: Question about ioctl interface - IO passthru
?
On Thu, Jan 31, 2019@4:56 PM Keith Busch <keith.busch@intel.com> wrote:
>
> On Thu, Jan 31, 2019@04:09:18PM +0200, Eyal BenDavid wrote:
> > What is the difference from using "nvme_user_io" structure?
> > Is it safe to use this version of IO commands?
>
> The passthru structure is good to use for any command. The
> nvme_user_io structure is a legacy feature from very early nvme days
> when read/write/compare were the only IO commands. It didn't extend to
> other IO commands, and deprecating it wouldn't be a bad thing.
Thanks!
A good start is to rewrite nvme read/write/compare commands using the
passthru structure instead of nvme_user_io.
---
Eyal
_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 6+ messages in thread
* Question about ioctl interface - IO passthru
2019-01-31 18:39 ` Chaitanya Kulkarni
@ 2019-01-31 19:05 ` Keith Busch
0 siblings, 0 replies; 6+ messages in thread
From: Keith Busch @ 2019-01-31 19:05 UTC (permalink / raw)
On Thu, Jan 31, 2019@06:39:28PM +0000, Chaitanya Kulkarni wrote:
> So I think it is a good start that to use the nvme_passthru command and make it more generic.
>
> Keith any comments on this ?
>
> or should we extend the nvme_user_io command with
> the new addition such as result field (less likely in my?opinion, may break IOCTL)??
Yeah, we can't break the ioctl ABI. :(
The only reason I haven't moved nvme-cli from user_io to passthru is
that user_io works on every nvme capable kernel, and it also supported
metadata long before passthru did. I think it's overdue, though, I'll
just add a new param for ancient-kernel compatibility mode to fallback
to the legacy user_io.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-31 19:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 14:09 Question about ioctl interface - IO passthru Eyal BenDavid
2019-01-31 14:55 ` Keith Busch
2019-01-31 18:08 ` Eyal BenDavid
2019-01-31 18:39 ` Chaitanya Kulkarni
2019-01-31 19:05 ` Keith Busch
-- strict thread matches above, loose matches on Subject: below --
2019-01-31 13:59 Eyal BenDavid
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox