dcavalca / rpms / systemd

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