]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.105/scsi-libsas-fix-rphy-phy_identifier-for-phys-with-end-devices-attached.patch
Linux 4.14.105
[thirdparty/kernel/stable-queue.git] / releases / 4.14.105 / scsi-libsas-fix-rphy-phy_identifier-for-phys-with-end-devices-attached.patch
1 From ffeafdd2bf0b280d67ec1a47ea6287910d271f3f Mon Sep 17 00:00:00 2001
2 From: John Garry <john.garry@huawei.com>
3 Date: Fri, 15 Feb 2019 00:37:57 +0800
4 Subject: scsi: libsas: Fix rphy phy_identifier for PHYs with end devices attached
5
6 From: John Garry <john.garry@huawei.com>
7
8 commit ffeafdd2bf0b280d67ec1a47ea6287910d271f3f upstream.
9
10 The sysfs phy_identifier attribute for a sas_end_device comes from the rphy
11 phy_identifier value.
12
13 Currently this is not being set for rphys with an end device attached, so
14 we see incorrect symlinks from systemd disk/by-path:
15
16 root@localhost:~# ls -l /dev/disk/by-path/
17 total 0
18 lrwxrwxrwx 1 root root 9 Feb 13 12:26 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy0-lun-0 -> ../../sdb
19 lrwxrwxrwx 1 root root 10 Feb 13 12:26 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy0-lun-0-part1 -> ../../sdb1
20 lrwxrwxrwx 1 root root 10 Feb 13 12:26 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy0-lun-0-part2 -> ../../sdb2
21 lrwxrwxrwx 1 root root 10 Feb 13 12:26 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy0-lun-0-part3 -> ../../sdc3
22
23 Indeed, each sas_end_device phy_identifier value is 0:
24
25 root@localhost:/# more sys/class/sas_device/end_device-0\:0\:2/phy_identifier
26 0
27 root@localhost:/# more sys/class/sas_device/end_device-0\:0\:10/phy_identifier
28 0
29
30 This patch fixes the discovery code to set the phy_identifier. With this,
31 we now get proper symlinks:
32
33 root@localhost:~# ls -l /dev/disk/by-path/
34 total 0
35 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy10-lun-0 -> ../../sdg
36 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy11-lun-0 -> ../../sdh
37 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy2-lun-0 -> ../../sda
38 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy2-lun-0-part1 -> ../../sda1
39 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy3-lun-0 -> ../../sdb
40 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy3-lun-0-part1 -> ../../sdb1
41 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy3-lun-0-part2 -> ../../sdb2
42 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy4-lun-0 -> ../../sdc
43 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy4-lun-0-part1 -> ../../sdc1
44 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy4-lun-0-part2 -> ../../sdc2
45 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy4-lun-0-part3 -> ../../sdc3
46 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy5-lun-0 -> ../../sdd
47 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy7-lun-0 -> ../../sde
48 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy7-lun-0-part1 -> ../../sde1
49 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy7-lun-0-part2 -> ../../sde2
50 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy7-lun-0-part3 -> ../../sde3
51 lrwxrwxrwx 1 root root 9 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy8-lun-0 -> ../../sdf
52 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy8-lun-0-part1 -> ../../sdf1
53 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy8-lun-0-part2 -> ../../sdf2
54 lrwxrwxrwx 1 root root 10 Feb 13 11:53 platform-HISI0162:01-sas-exp0x500e004aaaaaaa1f-phy8-lun-0-part3 -> ../../sdf3
55
56 Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
57 Reported-by: dann frazier <dann.frazier@canonical.com>
58 Signed-off-by: John Garry <john.garry@huawei.com>
59 Reviewed-by: Jason Yan <yanaijie@huawei.com>
60 Tested-by: dann frazier <dann.frazier@canonical.com>
61 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
62 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
63
64 ---
65 drivers/scsi/libsas/sas_expander.c | 2 ++
66 1 file changed, 2 insertions(+)
67
68 --- a/drivers/scsi/libsas/sas_expander.c
69 +++ b/drivers/scsi/libsas/sas_expander.c
70 @@ -829,6 +829,7 @@ static struct domain_device *sas_ex_disc
71 rphy = sas_end_device_alloc(phy->port);
72 if (!rphy)
73 goto out_free;
74 + rphy->identify.phy_identifier = phy_id;
75
76 child->rphy = rphy;
77 get_device(&rphy->dev);
78 @@ -856,6 +857,7 @@ static struct domain_device *sas_ex_disc
79
80 child->rphy = rphy;
81 get_device(&rphy->dev);
82 + rphy->identify.phy_identifier = phy_id;
83 sas_fill_in_rphy(child, rphy);
84
85 list_add_tail(&child->disco_list_node, &parent->port->disco_list);