2014-03-18 16:21:15 +01:00
|
|
|
From 5cf46aa4339670afac386b1b0e630b739f3621c7 Mon Sep 17 00:00:00 2001
|
2013-04-23 11:39:56 +02:00
|
|
|
From: Robert Milasan <rmilasan@suse.com>
|
|
|
|
Date: Thu, 12 Jul 2012 15:56:34 +0000
|
2014-03-18 16:21:15 +01:00
|
|
|
Subject: [PATCH] Persistent by_path links for ata devices
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2014-03-18 16:21:15 +01:00
|
|
|
With newer kernel we have the 'port_no' attribute,
|
|
|
|
which allows us to construct a valid ata by-path link.
|
|
|
|
|
|
|
|
With this patch ATA links of the form
|
|
|
|
|
|
|
|
ata-<port>.[01]
|
|
|
|
|
|
|
|
(for master/slave devices) or
|
|
|
|
|
|
|
|
ata-<port>.<pmp>.0
|
|
|
|
|
|
|
|
(for devices behind port multipliers)
|
|
|
|
are generated.
|
|
|
|
|
|
|
|
References: bnc#770910,FATE#317063
|
|
|
|
|
|
|
|
Signed-off-by: Robert Milasan <rmilasan@suse.com>
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
2013-04-23 11:39:56 +02:00
|
|
|
---
|
2015-03-27 09:39:40 +01:00
|
|
|
src/udev/udev-builtin-path_id.c | 53 ++++++++++++++++++++++++++++++----------
|
2014-03-18 16:21:15 +01:00
|
|
|
1 file changed, 41 insertions(+), 12 deletions(-)
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
Index: systemd-221/src/udev/udev-builtin-path_id.c
|
2015-03-27 09:39:40 +01:00
|
|
|
===================================================================
|
2015-09-27 14:32:31 +02:00
|
|
|
--- systemd-221.orig/src/udev/udev-builtin-path_id.c
|
|
|
|
+++ systemd-221/src/udev/udev-builtin-path_id.c
|
|
|
|
@@ -447,6 +447,46 @@ static struct udev_device *handle_scsi_h
|
2013-04-23 11:39:56 +02:00
|
|
|
return parent;
|
2012-11-02 17:30:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+static struct udev_device *handle_ata(struct udev_device *parent, char **path)
|
|
|
|
+{
|
2014-03-18 16:21:15 +01:00
|
|
|
+ struct udev *udev = udev_device_get_udev(parent);
|
|
|
|
+ struct udev_device *hostdev, *portdev;
|
|
|
|
+ int host, bus, target, lun, port_no;
|
|
|
|
+ const char *name, *atahost, *port;
|
2012-11-02 17:30:32 +01:00
|
|
|
+
|
|
|
|
+ hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
|
|
|
|
+ if (hostdev == NULL)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ name = udev_device_get_sysname(parent);
|
|
|
|
+ if (sscanf(name, "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
2014-03-18 16:21:15 +01:00
|
|
|
+ /* The ata port is the parent of the SCSI host */
|
|
|
|
+ hostdev = udev_device_get_parent(hostdev);
|
|
|
|
+ atahost = udev_device_get_sysname(hostdev);
|
|
|
|
+ if (strncmp(atahost, "ata", 3))
|
2012-11-02 17:30:32 +01:00
|
|
|
+ return NULL;
|
|
|
|
+
|
2014-03-18 16:21:15 +01:00
|
|
|
+ /* ATA port number is found in 'port_no' attribute */
|
|
|
|
+ portdev = udev_device_new_from_subsystem_sysname(udev, "ata_port",
|
|
|
|
+ atahost);
|
|
|
|
+ port = udev_device_get_sysattr_value(portdev, "port_no");
|
|
|
|
+ if (!port || sscanf(port, "%d", &port_no) != 1) {
|
|
|
|
+ hostdev = NULL;
|
2012-11-02 17:30:32 +01:00
|
|
|
+ goto out;
|
|
|
|
+ }
|
2014-03-18 16:21:15 +01:00
|
|
|
+ if (bus != 0)
|
|
|
|
+ /* Devices behind port multiplier have a bus != 0*/
|
|
|
|
+ path_prepend(path, "ata-%u.%u.0", port_no, bus);
|
|
|
|
+ else
|
|
|
|
+ /* Master/slave are distinguished by target id */
|
|
|
|
+ path_prepend(path, "ata-%u.%u", port_no, target);
|
2012-11-02 17:30:32 +01:00
|
|
|
+out:
|
2014-03-18 16:21:15 +01:00
|
|
|
+ udev_device_unref(portdev);
|
2012-11-02 17:30:32 +01:00
|
|
|
+ return hostdev;
|
|
|
|
+}
|
|
|
|
+
|
2015-03-27 09:39:40 +01:00
|
|
|
static struct udev_device *handle_scsi(struct udev_device *parent, char **path, bool *supported_parent) {
|
2012-11-02 17:30:32 +01:00
|
|
|
const char *devtype;
|
2015-03-27 09:39:40 +01:00
|
|
|
const char *name;
|
2015-09-27 14:32:31 +02:00
|
|
|
@@ -486,19 +526,8 @@ static struct udev_device *handle_scsi(s
|
2012-11-02 17:30:32 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
- /*
|
2013-04-23 11:39:56 +02:00
|
|
|
- * We do not support the ATA transport class, it uses global counters
|
|
|
|
- * to name the ata devices which numbers spread across multiple
|
|
|
|
- * controllers.
|
|
|
|
- *
|
|
|
|
- * The real link numbers are not exported. Also, possible chains of ports
|
|
|
|
- * behind port multipliers cannot be composed that way.
|
|
|
|
- *
|
|
|
|
- * Until all that is solved at the kernel level, there are no by-path/
|
|
|
|
- * links for ATA devices.
|
2012-11-02 17:30:32 +01:00
|
|
|
- */
|
|
|
|
if (strstr(name, "/ata") != NULL) {
|
|
|
|
- parent = NULL;
|
|
|
|
+ parent = handle_ata(parent, path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|