naccyde / rpms / systemd

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