diff options
author | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2013-07-08 17:26:25 -0400 |
---|---|---|
committer | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2013-09-03 16:32:26 -0400 |
commit | c3bfe7176c035a0a2c70bc79180fb13a6c57142a (patch) | |
tree | af979e07d60607e4d71faa3770b0ae3bd7005162 | |
parent | 685585c25e8269cc355b59d1cd6fc65b8c5c4878 (diff) |
NVMe: Namespace IDs are unsigned
The 'Number of Namespaces' read from the device was being treated as
signed, which would cause us to not scan any namespaces for a device
with more than 2 billion namespaces. That led to noticing that the
namespace ID was also being treated as signed, which could lead to the
result from NVME_IOCTL_ID being treated as an error code.
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
-rw-r--r-- | drivers/block/nvme-core.c | 7 | ||||
-rw-r--r-- | include/linux/nvme.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 07d527c66eb4..56d1fa472d06 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/moduleparam.h> | 36 | #include <linux/moduleparam.h> |
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/poison.h> | 38 | #include <linux/poison.h> |
39 | #include <linux/ptrace.h> | ||
39 | #include <linux/sched.h> | 40 | #include <linux/sched.h> |
40 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
41 | #include <linux/types.h> | 42 | #include <linux/types.h> |
@@ -1486,6 +1487,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | |||
1486 | 1487 | ||
1487 | switch (cmd) { | 1488 | switch (cmd) { |
1488 | case NVME_IOCTL_ID: | 1489 | case NVME_IOCTL_ID: |
1490 | force_successful_syscall_return(); | ||
1489 | return ns->ns_id; | 1491 | return ns->ns_id; |
1490 | case NVME_IOCTL_ADMIN_CMD: | 1492 | case NVME_IOCTL_ADMIN_CMD: |
1491 | return nvme_user_admin_cmd(ns->dev, (void __user *)arg); | 1493 | return nvme_user_admin_cmd(ns->dev, (void __user *)arg); |
@@ -1588,7 +1590,7 @@ static void nvme_config_discard(struct nvme_ns *ns) | |||
1588 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue); | 1590 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue); |
1589 | } | 1591 | } |
1590 | 1592 | ||
1591 | static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, int nsid, | 1593 | static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid, |
1592 | struct nvme_id_ns *id, struct nvme_lba_range_type *rt) | 1594 | struct nvme_id_ns *id, struct nvme_lba_range_type *rt) |
1593 | { | 1595 | { |
1594 | struct nvme_ns *ns; | 1596 | struct nvme_ns *ns; |
@@ -1768,7 +1770,8 @@ static void nvme_free_queues(struct nvme_dev *dev) | |||
1768 | */ | 1770 | */ |
1769 | static int nvme_dev_add(struct nvme_dev *dev) | 1771 | static int nvme_dev_add(struct nvme_dev *dev) |
1770 | { | 1772 | { |
1771 | int res, nn, i; | 1773 | int res; |
1774 | unsigned nn, i; | ||
1772 | struct nvme_ns *ns; | 1775 | struct nvme_ns *ns; |
1773 | struct nvme_id_ctrl *ctrl; | 1776 | struct nvme_id_ctrl *ctrl; |
1774 | struct nvme_id_ns *id_ns; | 1777 | struct nvme_id_ns *id_ns; |
diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 8d0041513e1a..3403c8f06fa0 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h | |||
@@ -104,7 +104,7 @@ struct nvme_ns { | |||
104 | struct request_queue *queue; | 104 | struct request_queue *queue; |
105 | struct gendisk *disk; | 105 | struct gendisk *disk; |
106 | 106 | ||
107 | int ns_id; | 107 | unsigned ns_id; |
108 | int lba_shift; | 108 | int lba_shift; |
109 | int ms; | 109 | int ms; |
110 | u64 mode_select_num_blocks; | 110 | u64 mode_select_num_blocks; |