Blame SOURCES/0186-udev-also-create-old-sas-paths.patch

17b0f1
From 956212c9a226d9192e4b3c085e917fe59f6d5cb9 Mon Sep 17 00:00:00 2001
17b0f1
From: Maurizio Lombardi <mlombard@redhat.com>
17b0f1
Date: Tue, 2 Jun 2015 17:26:25 +0200
17b0f1
Subject: [PATCH] udev: also create old sas paths
17b0f1
17b0f1
RHEL-only
17b0f1
17b0f1
Resolves: #957112
17b0f1
---
17b0f1
 rules/60-persistent-storage.rules |  2 ++
17b0f1
 src/udev/udev-builtin-path_id.c   | 33 ++++++++++++++++++++++++-------
17b0f1
 2 files changed, 28 insertions(+), 7 deletions(-)
17b0f1
17b0f1
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
17b0f1
index 25b44a55cb..71ab974844 100644
17b0f1
--- a/rules/60-persistent-storage.rules
17b0f1
+++ b/rules/60-persistent-storage.rules
17b0f1
@@ -54,7 +54,9 @@ KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+=
17b0f1
 # by-path (parent device path)
17b0f1
 ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
17b0f1
 ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
17b0f1
+ENV{DEVTYPE}=="disk", ENV{ID_SAS_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_SAS_PATH}"
17b0f1
 ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
17b0f1
+ENV{DEVTYPE}=="partition", ENV{ID_SAS_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_SAS_PATH}-part%n"
17b0f1
 
17b0f1
 # skip unpartitioned removable media devices from drivers which do not send "change" events
17b0f1
 ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
17b0f1
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
17b0f1
index bb0a6242ac..025392df5b 100644
17b0f1
--- a/src/udev/udev-builtin-path_id.c
17b0f1
+++ b/src/udev/udev-builtin-path_id.c
17b0f1
@@ -154,7 +154,7 @@ out:
17b0f1
         return parent;
17b0f1
 }
17b0f1
 
17b0f1
-static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path)
17b0f1
+static struct udev_device *handle_scsi_sas(struct udev_device *parent, bool enable_new_sas_path, char **path, bool *new_sas_path)
17b0f1
 {
17b0f1
         struct udev *udev  = udev_device_get_udev(parent);
17b0f1
         struct udev_device *targetdev;
17b0f1
@@ -169,6 +169,8 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
17b0f1
         const char *phy_count;
17b0f1
         char *lun = NULL;
17b0f1
 
17b0f1
+        *new_sas_path = false;
17b0f1
+
17b0f1
         targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
17b0f1
         if (targetdev == NULL)
17b0f1
                 return NULL;
17b0f1
@@ -201,7 +203,7 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
17b0f1
         }
17b0f1
 
17b0f1
         /* Check if we are simple disk */
17b0f1
-        if (strncmp(phy_count, "1", 2) != 0) {
17b0f1
+        if (strncmp(phy_count, "1", 2) != 0 || !enable_new_sas_path) {
17b0f1
                  parent = handle_scsi_sas_wide_port(parent, path);
17b0f1
                  goto out;
17b0f1
         }
17b0f1
@@ -241,6 +243,8 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
17b0f1
 
17b0f1
         if (lun)
17b0f1
                 free(lun);
17b0f1
+
17b0f1
+        *new_sas_path = true;
17b0f1
 out:
17b0f1
         udev_device_unref(target_sasdev);
17b0f1
         udev_device_unref(expander_sasdev);
17b0f1
@@ -466,7 +470,7 @@ out:
17b0f1
         return hostdev;
17b0f1
 }
17b0f1
 
17b0f1
-static struct udev_device *handle_scsi(struct udev_device *parent, char **path, bool *supported_parent) {
17b0f1
+static struct udev_device *handle_scsi(struct udev_device *parent, bool enable_new_sas_path, char **path, bool *supported_parent, bool *new_sas_path) {
17b0f1
         const char *devtype;
17b0f1
         const char *name;
17b0f1
         const char *id;
17b0f1
@@ -494,7 +498,7 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path,
17b0f1
         }
17b0f1
 
17b0f1
         if (strstr(name, "/end_device-") != NULL) {
17b0f1
-                parent = handle_scsi_sas(parent, path);
17b0f1
+                parent = handle_scsi_sas(parent, enable_new_sas_path, path, new_sas_path);
17b0f1
                 *supported_parent = true;
17b0f1
                 goto out;
17b0f1
         }
17b0f1
@@ -610,6 +614,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
17b0f1
         char *path = NULL;
17b0f1
         bool supported_transport = false;
17b0f1
         bool supported_parent = false;
17b0f1
+        bool new_sas_path = false;
17b0f1
+        bool enable_new_sas_path = true;
17b0f1
 
17b0f1
         /* S390 ccw bus */
17b0f1
         parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL);
17b0f1
@@ -618,6 +624,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
17b0f1
                 goto out;
17b0f1
         }
17b0f1
 
17b0f1
+restart:
17b0f1
+        ;
17b0f1
         /* walk up the chain of devices and compose path */
17b0f1
         parent = dev;
17b0f1
         while (parent != NULL) {
17b0f1
@@ -629,7 +637,7 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
17b0f1
                 } else if (streq(subsys, "scsi_tape")) {
17b0f1
                         handle_scsi_tape(parent, &path);
17b0f1
                 } else if (streq(subsys, "scsi")) {
17b0f1
-                        parent = handle_scsi(parent, &path, &supported_parent);
17b0f1
+                        parent = handle_scsi(parent, enable_new_sas_path, &path, &supported_parent, &new_sas_path);
17b0f1
                         supported_transport = true;
17b0f1
                 } else if (streq(subsys, "cciss")) {
17b0f1
                         parent = handle_cciss(parent, &path);
17b0f1
@@ -721,9 +729,20 @@ out:
17b0f1
                         i--;
17b0f1
                 tag[i] = '\0';
17b0f1
 
17b0f1
-                udev_builtin_add_property(dev, test, "ID_PATH", path);
17b0f1
-                udev_builtin_add_property(dev, test, "ID_PATH_TAG", tag);
17b0f1
+                if (new_sas_path) {
17b0f1
+                        udev_builtin_add_property(dev, test, "ID_SAS_PATH", path);
17b0f1
+                } else {
17b0f1
+                        udev_builtin_add_property(dev, test, "ID_PATH", path);
17b0f1
+                        udev_builtin_add_property(dev, test, "ID_PATH_TAG", tag);
17b0f1
+                }
17b0f1
+
17b0f1
                 free(path);
17b0f1
+
17b0f1
+                if (new_sas_path) {
17b0f1
+                        enable_new_sas_path = false;
17b0f1
+                        goto restart;
17b0f1
+                }
17b0f1
+
17b0f1
                 return EXIT_SUCCESS;
17b0f1
         }
17b0f1
         return EXIT_FAILURE;