linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFD] passthrough ioctl interface considered harmful?
@ 2018-01-24 15:01 Johannes Thumshirn
  2018-01-24 15:59 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2018-01-24 15:01 UTC (permalink / raw)


Hey @all,

Inspired by the discussion at [1] I've distilled a small test-case [1] which
deletes QID 1 submission and completions queues. When running this while I/O
is in-flight we obviously get timeouts and thus force controller resets.

For some commands commands (nvme_admin_format_nvm, nvme_admin_sanitize_nvm) we
do already check whether it is a good idea or not and at least warn the user
about the possible side effects.

Question here is, should we extend the list and/or block specific commands (at
least while I/O is running)?

Thanks,
	Johannes

[1] http://lists.infradead.org/pipermail/linux-nvme/2018-January/015181.html
[2]
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <stropts.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/nvme.h>

struct nvme_passthru_cmd {
        __u8    opcode;
        __u8    flags;
        __u16   rsvd1;
        __u32   nsid;
        __u32   cdw2;
        __u32   cdw3;
        __u64   metadata;
        __u64   addr;
        __u32   metadata_len;
        __u32   data_len;
        __u32   cdw10;
        __u32   cdw11;
        __u32   cdw12;
        __u32   cdw13;
        __u32   cdw14;
        __u32   cdw15;
        __u32   timeout_ms;
        __u32   result;
};
#define nvme_admin_cmd nvme_passthru_cmd
#define NVME_IOCTL_ADMIN_CMD    _IOWR('N', 0x41, struct nvme_admin_cmd)


int main(void)
{
	struct nvme_delete_queue cmd = { 0 };
	int fd;
	int ret;

	fd = open("/dev/nvme0n1", O_RDWR);
	if (fd < 0) {
		perror("open");
		return 1;
	}

	cmd.qid = 1;

	cmd.opcode = nvme_admin_delete_cq;
	ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
	if (ret < 0)
		perror("ioctl");

	cmd.opcode = nvme_admin_delete_sq;
	ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
	if (ret < 0)
		perror("ioctl");

	close(fd);

	return 0;
}
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [RFD] passthrough ioctl interface considered harmful?
  2018-01-24 15:01 [RFD] passthrough ioctl interface considered harmful? Johannes Thumshirn
@ 2018-01-24 15:59 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2018-01-24 15:59 UTC (permalink / raw)


On Wed, Jan 24, 2018@04:01:01PM +0100, Johannes Thumshirn wrote:
> Inspired by the discussion at [1] I've distilled a small test-case [1] which
> deletes QID 1 submission and completions queues. When running this while I/O
> is in-flight we obviously get timeouts and thus force controller resets.
> 
> For some commands commands (nvme_admin_format_nvm, nvme_admin_sanitize_nvm) we
> do already check whether it is a good idea or not and at least warn the user
> about the possible side effects.
> 
> Question here is, should we extend the list and/or block specific commands (at
> least while I/O is running)?

I like to think if you misuse the interface, you get to keep both
pieces. With great power comes great responsibility.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-24 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-24 15:01 [RFD] passthrough ioctl interface considered harmful? Johannes Thumshirn
2018-01-24 15:59 ` Keith Busch

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).