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

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