Blame SOURCES/0043-Add-support-for-NVMe-devices.patch

9cc286
From 62cb6416f112dda0b0b969c1247cbc0f98314182 Mon Sep 17 00:00:00 2001
9cc286
From: Petr Uzel <petr.uzel@suse.cz>
9cc286
Date: Tue, 14 Jun 2016 13:17:00 +0200
9cc286
Subject: [PATCH] Add support for NVMe devices
9cc286
9cc286
Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints
9cc286
"NVMe Device (nvme)" instead of "Model: Unknown (unknown)".
9cc286
9cc286
In order for a device to be recognized as NVMe, it has to
9cc286
have a 'blkext' major number. But since this major can be
9cc286
used also by other device types, we also check the device
9cc286
path contains 'nvme' as a substring.
9cc286
9cc286
* NEWS: Mention the change
9cc286
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME
9cc286
* libparted/arch/linux.c(BLKEXT_MAJOR): New define.
9cc286
* libparted/arch/linux.c(_is_blkext_major): New function.
9cc286
* libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices.
9cc286
* libparted/arch/linux.c(linux_new): Handle NVMe devices.
9cc286
* parted/parted.c(do_print): Add "nvme" to list of transports.
9cc286
9cc286
Signed-off-by: Brian C. Lane <bcl@redhat.com>
9cc286
(cherry picked from commit e4ae4330f3e33201aeeed3b7ca88e15d98d03e13)
9cc286
9cc286
Resolves: rhbz#1316239
9cc286
---
9cc286
 NEWS                       |  4 ++++
9cc286
 include/parted/device.in.h |  3 ++-
9cc286
 libparted/arch/linux.c     | 14 ++++++++++++++
9cc286
 parted/parted.c            |  2 +-
9cc286
 4 files changed, 21 insertions(+), 2 deletions(-)
9cc286
9cc286
diff --git a/NEWS b/NEWS
9cc286
index d1ab2a6..d1a6f58 100644
9cc286
--- a/NEWS
9cc286
+++ b/NEWS
9cc286
@@ -1,5 +1,9 @@
9cc286
 GNU parted NEWS                                    -*- outline -*-
9cc286
 
9cc286
+* Noteworthy changes in release 3.1-29 (2017-04-11) [RHEL7.4]
9cc286
+
9cc286
+  Parted now recognizes NVMe devices
9cc286
+
9cc286
 * Noteworthy changes in release 3.1-18 (2014-08-12) [RHEL7.1]
9cc286
 
9cc286
 ** New features
9cc286
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
9cc286
index a3d1737..b0aa1f2 100644
9cc286
--- a/include/parted/device.in.h
9cc286
+++ b/include/parted/device.in.h
9cc286
@@ -49,7 +49,8 @@ typedef enum {
9cc286
         PED_DEVICE_VIRTBLK      = 15,
9cc286
         PED_DEVICE_AOE          = 16,
9cc286
         PED_DEVICE_MD           = 17,
9cc286
-        PED_DEVICE_LOOP         = 18
9cc286
+        PED_DEVICE_LOOP         = 18,
9cc286
+        PED_DEVICE_NVME         = 19
9cc286
 } PedDeviceType;
9cc286
 
9cc286
 typedef struct _PedDevice PedDevice;
9cc286
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
9cc286
index 341bbbb..fa329f4 100644
9cc286
--- a/libparted/arch/linux.c
9cc286
+++ b/libparted/arch/linux.c
9cc286
@@ -275,6 +275,7 @@ struct blkdev_ioctl_param {
9cc286
 #define SDMMC_MAJOR             179
9cc286
 #define LOOP_MAJOR              7
9cc286
 #define MD_MAJOR                9
9cc286
+#define BLKEXT_MAJOR            259
9cc286
 
9cc286
 #define SCSI_BLK_MAJOR(M) (                                             \
9cc286
                 (M) == SCSI_DISK0_MAJOR                                 \
9cc286
@@ -437,6 +438,12 @@ _is_virtblk_major (int major)
9cc286
         return _major_type_in_devices (major, "virtblk");
9cc286
 }
9cc286
 
9cc286
+static int
9cc286
+_is_blkext_major (int major)
9cc286
+{
9cc286
+        return _major_type_in_devices (major, "blkext");
9cc286
+}
9cc286
+
9cc286
 #ifdef ENABLE_DEVICE_MAPPER
9cc286
 static int
9cc286
 _is_dm_major (int major)
9cc286
@@ -600,6 +607,8 @@ _device_probe_type (PedDevice* dev)
9cc286
                 dev->type = PED_DEVICE_LOOP;
9cc286
         } else if (dev_major == MD_MAJOR) {
9cc286
                 dev->type = PED_DEVICE_MD;
9cc286
+        } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
9cc286
+                dev->type = PED_DEVICE_NVME;
9cc286
         } else {
9cc286
                 dev->type = PED_DEVICE_UNKNOWN;
9cc286
         }
9cc286
@@ -1372,6 +1381,11 @@ linux_new (const char* path)
9cc286
                         goto error_free_arch_specific;
9cc286
                 break;
9cc286
 
9cc286
+        case PED_DEVICE_NVME:
9cc286
+                if (!init_generic (dev, _("NVMe Device")))
9cc286
+                        goto error_free_arch_specific;
9cc286
+                break;
9cc286
+
9cc286
         case PED_DEVICE_ATARAID:
9cc286
                 if (!init_generic (dev, _("ATARAID Controller")))
9cc286
                         goto error_free_arch_specific;
9cc286
diff --git a/parted/parted.c b/parted/parted.c
9cc286
index 789030a..957789a 100644
9cc286
--- a/parted/parted.c
9cc286
+++ b/parted/parted.c
9cc286
@@ -947,7 +947,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *disk)
9cc286
                                          "cpqarray", "file", "ataraid", "i2o",
9cc286
                                          "ubd", "dasd", "viodasd", "sx8", "dm",
9cc286
                                          "xvd", "sd/mmc", "virtblk", "aoe",
9cc286
-                                         "md", "loopback"};
9cc286
+                                         "md", "loopback", "nvme"};
9cc286
 
9cc286
         char* start = ped_unit_format (dev, 0);
9cc286
         PedUnit default_unit = ped_unit_get_default ();
9cc286
-- 
9cc286
2.9.4
9cc286