]> Pileus Git - ~andy/linux/commitdiff
NVMe: Namespace IDs are unsigned
authorMatthew Wilcox <matthew.r.wilcox@intel.com>
Mon, 8 Jul 2013 21:26:25 +0000 (17:26 -0400)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Tue, 3 Sep 2013 20:32:26 +0000 (16:32 -0400)
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>
drivers/block/nvme-core.c
include/linux/nvme.h

index 07d527c66eb45aacbfeb6bc971f37bbaf0644776..56d1fa472d06c77d33ae8dfb654200d6270f47bb 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include <linux/poison.h>
+#include <linux/ptrace.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -1486,6 +1487,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
 
        switch (cmd) {
        case NVME_IOCTL_ID:
+               force_successful_syscall_return();
                return ns->ns_id;
        case NVME_IOCTL_ADMIN_CMD:
                return nvme_user_admin_cmd(ns->dev, (void __user *)arg);
@@ -1588,7 +1590,7 @@ static void nvme_config_discard(struct nvme_ns *ns)
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue);
 }
 
-static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, int nsid,
+static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid,
                        struct nvme_id_ns *id, struct nvme_lba_range_type *rt)
 {
        struct nvme_ns *ns;
@@ -1768,7 +1770,8 @@ static void nvme_free_queues(struct nvme_dev *dev)
  */
 static int nvme_dev_add(struct nvme_dev *dev)
 {
-       int res, nn, i;
+       int res;
+       unsigned nn, i;
        struct nvme_ns *ns;
        struct nvme_id_ctrl *ctrl;
        struct nvme_id_ns *id_ns;
index 8d0041513e1ab421d1d82deb3e184da1730560b3..3403c8f06fa0d73b546892705337e1d7c126556d 100644 (file)
@@ -104,7 +104,7 @@ struct nvme_ns {
        struct request_queue *queue;
        struct gendisk *disk;
 
-       int ns_id;
+       unsigned ns_id;
        int lba_shift;
        int ms;
        u64 mode_select_num_blocks;