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

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