Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better zfs_get_enclosure_sysfs_path() enclosure support #11617

Merged
merged 1 commit into from Feb 21, 2021

Conversation

tonyhutter
Copy link
Contributor

Motivation and Context

Update zfs_get_enclosure_sysfs_path() to work with more enclosures.

Description

A multpathed disk will have several 'underlying' paths to the disk. For example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}. On many enclosures those underlying sysfs paths will have a symlink back to their enclosure device entry (like 'enclosure_device0/slot1'). This is used by the statechange-led.sh script to set/clear the fault LED for a disk, and
by zpool status -c.

However, on some enclosures, those underlying paths may not all have symlinks back to the enclosure device. Maybe only two out of four of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning paths that have symlinks back to their enclosure devices, rather than just returning the first path.

How Has This Been Tested?

Tested by running:

ZPOOL_SCRIPTS_AS_ROOT=1 ./cmd/zpool/zpool status -c slot

Saw all VDEVs report their slot number with this patch, and about half reported it without the patch.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@tonyhutter tonyhutter added the Status: Work in Progress Not yet ready for general review label Feb 18, 2021
@tonyhutter
Copy link
Contributor Author

Marking as WIP since there's still one enclosure I need to test this on.

@ikozhukhov
Copy link
Contributor

i'd like propose to add kstat vdev what i have added to DilOS with output:

root@shelf9:~# kstat -c vdev xvol
module: xvol                            instance: 0
name:   0xfffffe236bdf7000              class:    vdev
        alloc                           0
        crtime                          698977.792241513
        devid                           id1,sd@n5000cca260d91529/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            12584263273525611962
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLHT5JBY
        size                            8001563222016
        slot                            7
        snaptime                        5193085.281819694
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260D91529d0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe236e97a000              class:    vdev
        alloc                           0
        crtime                          698977.790674145
        devid                           id1,sd@n5000cca05cdd7744/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            4698843023833777793
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKXTS9X
        size                            4000787030016
        slot                            5
        snaptime                        5193085.281463796
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDD7745d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe236ff80000              class:    vdev
        alloc                           1353991372800
        crtime                          698977.797231163
        devid                           (null)
        enclosure                       -1
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            2414103560827551895
        hba                             (null)
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             (null)
        rsize                           0
        serial                          (null)
        size                            0
        slot                            -1
        snaptime                        5193085.281844217
        space                           128007205289984
        state                           DEGRADED
        type                            raidz
        vdev_ashift                     12
        vdev_path                       (null)
        vid                             (null)

module: xvol                            instance: 0
name:   0xfffffe237013f000              class:    vdev
        alloc                           0
        crtime                          698977.791595390
        devid                           id1,sd@n5000cca25d1a250c/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            9240232892782037039
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GGBRXB
        size                            4000787033600
        slot                            5
        snaptime                        5193085.281665916
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D1A250Dd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe2377200000              class:    vdev
        alloc                           0
        crtime                          4909141.278463168
        devid                           id1,sd@n5000cca05cde9b30/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            8654817790542727446
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         1
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKYE5ZX
        size                            4000787030016
        slot                            11
        snaptime                        5193085.282065362
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     9
        vdev_path                       /dev/dsk/c3t5000CCA05CDE9B31d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe238107e000              class:    vdev
        alloc                           0
        crtime                          698977.791513456
        devid                           id1,sd@n5000cca25d177eb8/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            12632417003223344649
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GDXKHB
        size                            4000787033600
        slot                            22
        snaptime                        5193085.281629799
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D177EB9d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe245b2c1000              class:    vdev
        alloc                           0
        crtime                          698977.791447869
        devid                           id1,sd@n5000cca24316e96c/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            3610653637799381786
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          NHGDLM8Y
        size                            4000787033600
        slot                            4
        snaptime                        5193085.281579849
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA24316E96Dd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262b91c000              class:    vdev
        alloc                           0
        crtime                          698977.790789548
        devid                           id1,sd@n5000cca05cdd6994/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            10887512612719091903
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKXSV1X
        size                            4000787030016
        slot                            3
        snaptime                        5193085.281500387
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDD6995d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262cfa4000              class:    vdev
        alloc                           0
        crtime                          4909141.108180737
        devid                           id1,sd@n5000cca26098ee50/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            17913741624857829011
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         1
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJR39GV
        size                            8001563222016
        slot                            20
        snaptime                        5193085.282040328
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA26098EE51d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262cfac000              class:    vdev
        alloc                           0
        crtime                          698977.809395559
        devid                           id1,sd@n5000cca25d1869e4/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            6599887990639924996
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GEE70B
        size                            4000787033600
        slot                            7
        snaptime                        5193085.281855780
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D1869E5d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262cff0000              class:    vdev
        alloc                           0
        crtime                          698977.791880304
        devid                           id1,sd@n5000cca260dd069b/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            16030381296733521025
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLJ1VEEY
        size                            8001563222016
        slot                            8
        snaptime                        5193085.281754578
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260DD069Bd0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe262d090000              class:    vdev
        alloc                           0
        crtime                          4909211.984879945
        devid                           id1,sd@n5000cca05cdf6c90/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            5880904841007547426
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         1
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKYW47X
        size                            4000787030016
        slot                            9
        snaptime                        5193085.282078167
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDF6C91d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d0c6000              class:    vdev
        alloc                           0
        crtime                          698977.791589722
        devid                           id1,sd@n5000cca25d1269b4/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            14342082514273348179
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GA3XJB
        size                            4000787033600
        slot                            1
        snaptime                        5193085.281654283
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D1269B5d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d0da000              class:    vdev
        alloc                           0
        crtime                          4908954.226991782
        devid                           id1,sd@n5000cca26098ee50/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            395044501827832827
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         1
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJR39GV
        size                            8001563222016
        slot                            20
        snaptime                        5193085.282012749
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA26098EE51d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d10a000              class:    vdev
        alloc                           0
        crtime                          698977.790795236
        devid                           id1,sd@n5000cca05cdffa34/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            7409360535121221169
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKZ5KNX
        size                            4000787030016
        slot                            23
        snaptime                        5193085.281512671
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDFFA35d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d112000              class:    vdev
        alloc                           0
        crtime                          4909141.206726880
        devid                           id1,sd@n5000cca05cdf6c90/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            1516110979514521495
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         1
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKYW47X
        size                            4000787030016
        slot                            9
        snaptime                        5193085.282053406
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     9
        vdev_path                       /dev/dsk/c3t5000CCA05CDF6C91d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d11a000              class:    vdev
        alloc                           0
        crtime                          698977.790914830
        devid                           id1,sd@n5000cca05cdadc40/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            7249320116107420131
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKWBA7X
        size                            4000787030016
        slot                            8
        snaptime                        5193085.281536311
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDADC41d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d12a000              class:    vdev
        alloc                           0
        crtime                          698977.791710979
        devid                           id1,sd@n5000cca25d18330c/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            11336684124198944981
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GE9KTB
        size                            4000787033600
        slot                            2
        snaptime                        5193085.281742114
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D18330Dd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262d136000              class:    vdev
        alloc                           0
        crtime                          698977.792166459
        devid                           id1,sd@n5000cca260dc5721/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            3796657819887969532
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLJ0APAY
        size                            8001563222016
        slot                            12
        snaptime                        5193085.281807621
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260DC5721d0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe262d19e000              class:    vdev
        alloc                           0
        crtime                          698977.791618490
        devid                           id1,sd@n5000cca25d18c430/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            10992372110590314856
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GEM7EB
        size                            4000787033600
        slot                            6
        snaptime                        5193085.281678378
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D18C431d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea6b000              class:    vdev
        alloc                           0
        crtime                          698977.791421800
        devid                           id1,sd@n5000cca25d18fe6c/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            1319161191932323312
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS726040AL5210
        rsize                           0
        serial                          K4GES3NB
        size                            4000787033600
        slot                            17
        snaptime                        5193085.281567795
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA25D18FE6Dd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea77000              class:    vdev
        alloc                           0
        crtime                          698977.790714928
        devid                           id1,sd@n5000cca05cde9bbc/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            5928853684377159058
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKYE73X
        size                            4000787030016
        slot                            16
        snaptime                        5193085.281476174
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDE9BBDd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea8b000              class:    vdev
        alloc                           0
        crtime                          698977.791624338
        devid                           id1,sd@n5000cca2608bad34/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            17377172325998047793
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJGUAAV
        size                            8001563222016
        slot                            11
        snaptime                        5193085.281691172
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA2608BAD35d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea8f000              class:    vdev
        alloc                           0
        crtime                          698977.795988516
        devid                           id1,sd@n5000cca2608ff054/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            9435053679000993697
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJK4ZZV
        size                            8001563222016
        slot                            14
        snaptime                        5193085.281832682
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA2608FF055d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea93000              class:    vdev
        alloc                           0
        crtime                          698977.791634532
        devid                           id1,sd@n5000cca26098e4ec/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            7346924098367187113
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJR2P2V
        size                            8001563222016
        slot                            15
        snaptime                        5193085.281716934
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA26098E4EDd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea97000              class:    vdev
        alloc                           663728553984
        crtime                          698977.820848978
        devid                           (null)
        enclosure                       -1
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            11068074763641865472
        hba                             (null)
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             (null)
        rsize                           0
        serial                          (null)
        size                            0
        slot                            -1
        snaptime                        5193085.281869424
        space                           64012192579584
        state                           ONLINE
        type                            raidz
        vdev_ashift                     12
        vdev_path                       (null)
        vid                             (null)

module: xvol                            instance: 0
name:   0xfffffe262ea9b000              class:    vdev
        alloc                           0
        crtime                          698977.790649252
        devid                           id1,sd@n5000cca05cde4710/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            16961358572973982012
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKY7L9X
        size                            4000787030016
        slot                            4
        snaptime                        5193085.281449456
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDE4711d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262ea9f000              class:    vdev
        alloc                           0
        crtime                          698977.790745166
        devid                           id1,sd@n5000cca05cdecfe4/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            16537647888420677508
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKYJPTX
        size                            4000787030016
        slot                            0
        snaptime                        5193085.281488698
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CDECFE5d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eaa3000              class:    vdev
        alloc                           0
        crtime                          698977.790835466
        devid                           id1,sd@n5000cca05cd17edc/a
        enclosure                       3
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            1670343099290667825
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUS724040ALS640
        rsize                           0
        serial                          PCKR6NTX
        size                            4000787030016
        slot                            10
        snaptime                        5193085.281524511
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA05CD17EDDd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eaab000              class:    vdev
        alloc                           0
        crtime                          698977.791901056
        devid                           id1,sd@n5000cca260d8c63d/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            5601665231603945666
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLHSHHMY
        size                            8001563222016
        slot                            19
        snaptime                        5193085.281768065
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260D8C63Dd0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe262eaaf000              class:    vdev
        alloc                           0
        crtime                          698977.792082654
        devid                           id1,sd@n5000cca260dc464b/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            14848868126227741722
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLJ0669Y
        size                            8001563222016
        slot                            21
        snaptime                        5193085.281781514
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260DC464Bd0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe262eab3000              class:    vdev
        alloc                           0
        crtime                          698977.791492348
        devid                           id1,sd@n5000cca2608fef48/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            7917279717570125199
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJK4XUV
        size                            8001563222016
        slot                            0
        snaptime                        5193085.281605340
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA2608FEF49d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eab7000              class:    vdev
        alloc                           0
        crtime                          698977.791626813
        devid                           id1,sd@n5000cca26098ddfc/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            13198133970793542343
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJR26SV
        size                            8001563222016
        slot                            1
        snaptime                        5193085.281704210
        space                           0
        state                           OFFLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA26098DDFDd0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eabb000              class:    vdev
        alloc                           0
        crtime                          698977.791655607
        devid                           id1,sd@n5000cca2608fee50/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            8327024661975349677
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJK4VUV
        size                            8001563222016
        slot                            2
        snaptime                        5193085.281729678
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA2608FEE51d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eabf000              class:    vdev
        alloc                           0
        crtime                          698977.791500034
        devid                           id1,sd@n5000cca260988c60/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            2788784136261883656
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJPWT8V
        size                            8001563222016
        slot                            3
        snaptime                        5193085.281617937
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA260988C61d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eac3000              class:    vdev
        alloc                           0
        crtime                          698977.791538477
        devid                           id1,sd@n5000cca26098e220/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            9288958381420771350
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJR2H9V
        size                            8001563222016
        slot                            9
        snaptime                        5193085.281642384
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA26098E221d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eac7000              class:    vdev
        alloc                           0
        crtime                          698977.791368019
        devid                           id1,sd@n5000cca2608ff154/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            8648534347874093849
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HUH728080AL4204
        rsize                           0
        serial                          VLJK521V
        size                            8001563222016
        slot                            10
        snaptime                        5193085.281548483
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c3t5000CCA2608FF155d0s0
        vid                             HGST

module: xvol                            instance: 0
name:   0xfffffe262eae3000              class:    vdev
        alloc                           0
        crtime                          698977.792142407
        devid                           id1,sd@n5000cca260dd415d/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            7950676721566191011
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLJ2B2NY
        size                            8001563222016
        slot                            13
        snaptime                        5193085.281795159
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260DD415Dd0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffe262eae7000              class:    vdev
        alloc                           0
        crtime                          698977.791461834
        devid                           id1,sd@n5000cca260dc840a/a
        enclosure                       2
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            16357119527953622099
        hba                             mpt_sas0
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             HGST HUH728080AL
        rsize                           0
        serial                          VLJ0RN6Y
        size                            8001563222016
        slot                            18
        snaptime                        5193085.281592536
        space                           0
        state                           ONLINE
        type                            disk
        vdev_ashift                     12
        vdev_path                       /dev/dsk/c0t5000CCA260DC840Ad0s0
        vid                             ATA

module: xvol                            instance: 0
name:   0xfffffebb94ebc000              class:    vdev
        alloc                           0
        crtime                          4908990.399683911
        devid                           (null)
        enclosure                       0
        errors_checksum                 0
        errors_read                     0
        errors_slow                     0
        errors_write                    0
        esize                           0
        guid                            11841513213655788206
        hba                             (null)
        isl2cache                       0
        islog                           0
        isspare                         0
        nonrot                          0
        pid                             (null)
        rsize                           0
        serial                          (null)
        size                            0
        slot                            0
        snaptime                        5193085.282027782
        space                           0
        state                           ONLINE
        type                            spare
        vdev_ashift                     12
        vdev_path                       (null)
        vid                             (null)

A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
@tonyhutter
Copy link
Contributor Author

i'd like propose to add kstat vdev what i have added to DilOS with output:

I'm not sure I understand what you mean. This PR only affects Linux, not DilOS (Illumos).

@tonyhutter
Copy link
Contributor Author

This works on our three enclosure types. Removing WIP tag.

@tonyhutter tonyhutter removed the Status: Work in Progress Not yet ready for general review label Feb 20, 2021
if (!path) {
/*
* None of the underlying paths had a link back to their
* enclosure devices. Throw up out hands and return the first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* enclosure devices. Throw up out hands and return the first
* enclosure devices. Throw up our hands and return the first

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Feb 20, 2021
@behlendorf behlendorf merged commit 7e56b05 into openzfs:master Feb 21, 2021
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#11617
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#11617
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Nov 2, 2021
A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#11617
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Nov 13, 2021
A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#11617
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Nov 13, 2021
A multpathed disk will have several 'underlying' paths to the disk.  For
example, multipath disk 'dm-0' may be made up of paths:
/dev/{sda,sdb,sdc,sdd}.  On many enclosures those underlying sysfs
paths will have a symlink back to their enclosure device entry
(like 'enclosure_device0/slot1').  This is used by the
statechange-led.sh script to set/clear the fault LED for a disk, and
by 'zpool status -c'.

However, on some enclosures, those underlying paths may not all have
symlinks back to the enclosure device.  Maybe only two out of four
of them might.

This patch updates zfs_get_enclosure_sysfs_path() to favor returning
paths that have symlinks back to their enclosure devices, rather
than just returning the first path.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#11617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants