Skip to contentSkip to conversation

NVMe driver updates

GIT PULL Matthew Wilcox 2 participants 2 messages May 9, 2013 – Jun 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Linus,

Lots of exciting new features in the NVM Express driver this time, including support for emulating SCSI commands, discard support and the ability to submit per-sector metadata with I/Os. It's still mostly bugfixes though!

The following changes since commit a12183c62717ac4579319189a00f5883a18dff08:

Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip (2013-03-25 18:03:34 -0700)

are available in the git repository at:

git://git.infradead.org/users/willy/linux-nvme.git master

for you to fetch changes up to 94f370cab6e5ac514b658c6b2b3aa308cefc5c7a:

NVMe: Use user defined admin ioctl timeout (2013-05-09 16:03:50 -0400)

----------------------------------------------------------------
Arjan van de Ven (2):
NVMe: Use round_jiffies_relative() for the periodic, once-per-second timer
NVMe: Set TASK_INTERRUPTIBLE before processing queues

Keith Busch (13):
NVMe: Add discard support for capable devices
NVMe: Add a character device for each nvme device
NVMe: queue usage fixes in nvme-scsi
NVMe: Add scsi unmap to SG_IO
NVMe: Free admin queue on request_irq error
NVMe: Fix error clean-up on nvme_alloc_queue
NVMe: Check for NULL memory in nvme_dev_add
NVMe: Remove dead code in nvme_dev_add
NVMe: Split non-mergeable bio requests
NVMe: Device specific stripe size handling
NVMe: Meta-data support in NVME_IOCTL_SUBMIT_IO
NVMe: Schedule timeout for sync commands
NVMe: Use user defined admin ioctl timeout

Matthew Wilcox (7):
NVMe: Abstract out sector to block number conversion
NVMe: Don't fail initialisation unnecessarily
NVMe: Fix I/O cancellation status on big-endian machines
NVMe: Fix endian-related problems in user I/O submission path
NVMe: Wait for device to acknowledge shutdown
NVMe: Only clear the enable bit when disabling controller
NVMe: Simplify Firmware Activate code slightly

Vishal Verma (5):
NVMe: Rename nvme.c to nvme-core.c
NVMe: Move structures & definitions to header file
NVMe: Add definitions for format command
NVMe: Add nvme-scsi.c
NVMe: Fix sparse warnings in scsi emulation

 drivers/block/Makefile                |    1 +
 drivers/block/{nvme.c => nvme-core.c} |  594 +++++--
 drivers/block/nvme-scsi.c             | 3053 +++++++++++++++++++++++++++++++++
 include/linux/nvme.h                  |  158 +-
 4 files changed, 3640 insertions(+), 166 deletions(-)
 rename drivers/block/{nvme.c => nvme-core.c} (79%)
 create mode 100644 drivers/block/nvme-scsi.c
#1 lore raw

Re: NVMe: Add nvme-scsi.c (was Re: [PULL REQUEST] NVMe driver updates)

Il 09/05/2013 22:20, Matthew Wilcox ha scritto:

Quoted 1 line

NVMe: Add nvme-scsi.c

I couldn't find the original patch on LKML, so I'll just quote the relevant piece of code.

Review

Quoted 7 lines
(quoted diff) +7 -0
+int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr)
+{
+	struct sg_io_hdr hdr;
+	int retcode;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EACCES;

This should be EPERM, and also it should use the same checks as other implementations of SG_IO, including:

- checking if it's operating on a partition, and requiring CAP_SYS_RAWIO if so;

- allowing a limited number of commands even for !capable(CAP_SYS_RAWIO).

All this is done by scsi_cmd_blk_ioctl.

Paolo

Quoted 17 lines
(quoted diff) +17 -0
+	if (copy_from_user(&hdr, u_hdr, sizeof(hdr)))
+		return -EFAULT;
+	if (hdr.interface_id != 'S')
+		return -EINVAL;
+	if (hdr.cmd_len > BLK_MAX_CDB)
+		return -EINVAL;
+
+	retcode = nvme_scsi_translate(ns, &hdr);
+	if (retcode < 0)
+		return retcode;
+	if (retcode > 0)
+		retcode = SNTI_TRANSLATION_SUCCESS;
+	if (copy_to_user(__user u_hdr, &hdr, sizeof(sg_io_hdr_t)) > 0)
+		return -EFAULT;
+
+	return retcode;
+}