From: mwilck@suse.com To: Douglas Gilbert <dgilbert@interlog.com>, Hannes Reinecke <hare@suse.de> Cc: James Bottomley <jejb@linux.vnet.ibm.com>, linux-scsi@vger.kernel.org, "Martin K. Petersen" <martin.petersen@oracle.com>, Franck Bui <fbui@suse.de>, dm-devel@redhat.com, Martin Wilck <mwilck@suse.com> Subject: [dm-devel] [PATCH 2/3] 58-scsi-sg3_symlink.rules: don't create extra by-id symlinks by default Date: Mon, 27 Mar 2023 15:24:58 +0200 [thread overview] Message-ID: <20230327132459.29531-3-mwilck@suse.com> (raw) In-Reply-To: <20230327132459.29531-1-mwilck@suse.com> From: Martin Wilck <mwilck@suse.com> The current code will set device symlinks for every identifier obtained from VPD pages 0x83 and 0x80. This is seldom useful. Device IDs shouldn't be used for identifying file systems or high-level objects such as LVs; it is much more useful to identify these by their respective UUIDs. Those subsystems that need device IDs, such as LVM, multipath, dm-crypt etc, just need one identifier. For these use cases, a single symlink is sufficient, and it should be the most reliable one as selected by the ID_SERIAL logic in 55-scsi-sg3_id.rules. On the other hand, especially on large configurations, unreliable and ambiguous device identifiers can cause trouble when many devices claim the same symlink. udev's attempts to determine the highest-priority contender for a given symlink may be very resource-intensive and slow, especially during boot, when lots of uevents for similar devices have to be processed in parallel. This can cause udev workers to be killed, and in the worst case, boot failure. Avoid these issues by not creating possibly ambiguous /dev/disk/by-id symlinks any more by default. Users can modify the configuration by setting the types of symlinks to create in the environment variable .SCSI_SYMLINK_SRC, which can be a combination of the letters T, L, V, S: T: T10 vendor ID ("1...") from VPD 0x83 L: NAA local ("33...") from VPD 0x83 V: vendor-specific ("0...") from VPD 0x83 S: vendor/model/serial number ("S...") from VPD 0x80 In practice, modifying this should only be necessary if legacy devices that don't provide any reliable identifiers are used as targets for dm-crypt or LVM. Signed-off-by: Martin Wilck <mwilck@suse.com> --- scripts/58-scsi-sg3_symlink.rules | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/scripts/58-scsi-sg3_symlink.rules b/scripts/58-scsi-sg3_symlink.rules index fe6b000..99fdc23 100644 --- a/scripts/58-scsi-sg3_symlink.rules +++ b/scripts/58-scsi-sg3_symlink.rules @@ -5,10 +5,36 @@ ACTION=="remove", GOTO="sg3_utils_symlink_end" SUBSYSTEM!="block", GOTO="sg3_utils_symlink_end" ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="sg3_utils_symlink_end" -# Select which identifier to use per default +# Enable or disable possibly ambiguous SCSI device symlinks under /dev/disk/by-id +# +# .SCSI_SYMLINK_SRC can be any combination of the letter "TLVS": +# T: T10 vendor ID ("1...") from VPD 0x83 +# L: NAA local ("33...") from VPD 0x83 +# V: vendor-specific ("0...") from VPD 0x83 +# S: vendor/model/serial number ("S...") from VPD 0x80 +# Symlinks will be created for every letter included in .SCSI_SYMLINK_SRC. +# Symlinks for NAA (except "local") and EUI-64 IDs (see below) are always created. +# +# NOTE: The default rules in 60-persistent-storage.rules create a symlink +# "ENV{ID_BUS}-ENV{ID_SERIAL}" symlink anyway, where ID_BUS is "scsi", "ata", "usb", or "cciss". +# ID_SERIAL is set in 55-scsi-sg3_id.rules from the least ambiguous device identifier. +# The symlinks created by this file are created *in addition* to the default symlink. +# +# This only needs to be changed if some subsystem, like dm-crypt or LVM, depends on the +# additional symlinks being present for device identification. +# +# To configure the behavior, add an early rule (e.g. /etc/udev/rules.d/00-scsi-serial.rules) +# like this: +# ACTION!="remove", KERNEL=="sd*|sr*|st*|nst*|cciss*", ENV{.SCSI_SYMLINK_SRC}="TS" +# +# By default, no possibly ambiguous additional symlinks will be created. +ENV{.SCSI_SYMLINK_SRC}!="?*", ENV{.SCSI_SYMLINK_SRC}="" + # 0: vpd page 0x80 identifier -ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}" -ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*S*", ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}" +ENV{.SCSI_SYMLINK_SRC}=="*S*", ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}-part%n" # NAA identifier (prefix 3) # 1: IEEE Registered Extended first ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_REGEXT}" @@ -26,13 +52,19 @@ ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}" ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}-part%n" # 6: T10 Vendor identifier (prefix 1) -ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}" -ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*T*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}" +ENV{.SCSI_SYMLINK_SRC}=="*T*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}-part%n" # 7: IEEE Locally assigned -ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}" -ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*L*", ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}" +ENV{.SCSI_SYMLINK_SRC}=="*L*", ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}-part%n" # 8: Vendor-specific identifier (prefix 0) -ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}" -ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*V*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}" +ENV{.SCSI_SYMLINK_SRC}=="*V*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}-part%n" LABEL="sg3_utils_symlink_end" -- 2.39.2 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
WARNING: multiple messages have this Message-ID (diff)
From: mwilck@suse.com To: Douglas Gilbert <dgilbert@interlog.com>, Hannes Reinecke <hare@suse.de> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>, James Bottomley <jejb@linux.vnet.ibm.com>, Franck Bui <fbui@suse.de>, dm-devel@redhat.com, linux-scsi@vger.kernel.org, Benjamin Marzinski <bmarzins@redhat.com>, Martin Wilck <mwilck@suse.com> Subject: [PATCH 2/3] 58-scsi-sg3_symlink.rules: don't create extra by-id symlinks by default Date: Mon, 27 Mar 2023 15:24:58 +0200 [thread overview] Message-ID: <20230327132459.29531-3-mwilck@suse.com> (raw) In-Reply-To: <20230327132459.29531-1-mwilck@suse.com> From: Martin Wilck <mwilck@suse.com> The current code will set device symlinks for every identifier obtained from VPD pages 0x83 and 0x80. This is seldom useful. Device IDs shouldn't be used for identifying file systems or high-level objects such as LVs; it is much more useful to identify these by their respective UUIDs. Those subsystems that need device IDs, such as LVM, multipath, dm-crypt etc, just need one identifier. For these use cases, a single symlink is sufficient, and it should be the most reliable one as selected by the ID_SERIAL logic in 55-scsi-sg3_id.rules. On the other hand, especially on large configurations, unreliable and ambiguous device identifiers can cause trouble when many devices claim the same symlink. udev's attempts to determine the highest-priority contender for a given symlink may be very resource-intensive and slow, especially during boot, when lots of uevents for similar devices have to be processed in parallel. This can cause udev workers to be killed, and in the worst case, boot failure. Avoid these issues by not creating possibly ambiguous /dev/disk/by-id symlinks any more by default. Users can modify the configuration by setting the types of symlinks to create in the environment variable .SCSI_SYMLINK_SRC, which can be a combination of the letters T, L, V, S: T: T10 vendor ID ("1...") from VPD 0x83 L: NAA local ("33...") from VPD 0x83 V: vendor-specific ("0...") from VPD 0x83 S: vendor/model/serial number ("S...") from VPD 0x80 In practice, modifying this should only be necessary if legacy devices that don't provide any reliable identifiers are used as targets for dm-crypt or LVM. Signed-off-by: Martin Wilck <mwilck@suse.com> --- scripts/58-scsi-sg3_symlink.rules | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/scripts/58-scsi-sg3_symlink.rules b/scripts/58-scsi-sg3_symlink.rules index fe6b000..99fdc23 100644 --- a/scripts/58-scsi-sg3_symlink.rules +++ b/scripts/58-scsi-sg3_symlink.rules @@ -5,10 +5,36 @@ ACTION=="remove", GOTO="sg3_utils_symlink_end" SUBSYSTEM!="block", GOTO="sg3_utils_symlink_end" ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="sg3_utils_symlink_end" -# Select which identifier to use per default +# Enable or disable possibly ambiguous SCSI device symlinks under /dev/disk/by-id +# +# .SCSI_SYMLINK_SRC can be any combination of the letter "TLVS": +# T: T10 vendor ID ("1...") from VPD 0x83 +# L: NAA local ("33...") from VPD 0x83 +# V: vendor-specific ("0...") from VPD 0x83 +# S: vendor/model/serial number ("S...") from VPD 0x80 +# Symlinks will be created for every letter included in .SCSI_SYMLINK_SRC. +# Symlinks for NAA (except "local") and EUI-64 IDs (see below) are always created. +# +# NOTE: The default rules in 60-persistent-storage.rules create a symlink +# "ENV{ID_BUS}-ENV{ID_SERIAL}" symlink anyway, where ID_BUS is "scsi", "ata", "usb", or "cciss". +# ID_SERIAL is set in 55-scsi-sg3_id.rules from the least ambiguous device identifier. +# The symlinks created by this file are created *in addition* to the default symlink. +# +# This only needs to be changed if some subsystem, like dm-crypt or LVM, depends on the +# additional symlinks being present for device identification. +# +# To configure the behavior, add an early rule (e.g. /etc/udev/rules.d/00-scsi-serial.rules) +# like this: +# ACTION!="remove", KERNEL=="sd*|sr*|st*|nst*|cciss*", ENV{.SCSI_SYMLINK_SRC}="TS" +# +# By default, no possibly ambiguous additional symlinks will be created. +ENV{.SCSI_SYMLINK_SRC}!="?*", ENV{.SCSI_SYMLINK_SRC}="" + # 0: vpd page 0x80 identifier -ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}" -ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*S*", ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}" +ENV{.SCSI_SYMLINK_SRC}=="*S*", ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}-part%n" # NAA identifier (prefix 3) # 1: IEEE Registered Extended first ENV{SCSI_IDENT_LUN_NAA_REGEXT}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_REGEXT}" @@ -26,13 +52,19 @@ ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}" ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}-part%n" # 6: T10 Vendor identifier (prefix 1) -ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}" -ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*T*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}" +ENV{.SCSI_SYMLINK_SRC}=="*T*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}-part%n" # 7: IEEE Locally assigned -ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}" -ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*L*", ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}" +ENV{.SCSI_SYMLINK_SRC}=="*L*", ENV{SCSI_IDENT_LUN_NAA_LOCAL}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA_LOCAL}-part%n" # 8: Vendor-specific identifier (prefix 0) -ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}" -ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}-part%n" +ENV{.SCSI_SYMLINK_SRC}=="*V*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="disk", \ + SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}" +ENV{.SCSI_SYMLINK_SRC}=="*V*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="partition", \ + SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}-part%n" LABEL="sg3_utils_symlink_end" -- 2.39.2
next prev parent reply other threads:[~2023-03-27 13:25 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-27 13:24 [dm-devel] [RFC PATCH 0/3] sg3_utils: udev rules: restrict use of ambiguous device IDs mwilck 2023-03-27 13:24 ` mwilck 2023-03-27 13:24 ` [dm-devel] [PATCH 1/3] 55-scsi-sg3_id.rules: don't set unreliable device ID by default mwilck 2023-03-27 13:24 ` mwilck 2023-03-27 13:24 ` mwilck [this message] 2023-03-27 13:24 ` [PATCH 2/3] 58-scsi-sg3_symlink.rules: don't create extra by-id symlinks " mwilck 2023-03-27 13:24 ` [dm-devel] [PATCH 3/3] udev: add 00-scsi-sg3_config.rules for user configuration mwilck 2023-03-27 13:24 ` mwilck 2023-03-27 23:58 ` [RFC PATCH 0/3] sg3_utils: udev rules: restrict use of ambiguous device IDs Douglas Gilbert 2023-03-27 23:58 ` [dm-devel] " Douglas Gilbert 2023-03-28 7:52 ` Martin Wilck 2023-03-28 7:52 ` [dm-devel] " Martin Wilck
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230327132459.29531-3-mwilck@suse.com \ --to=mwilck@suse.com \ --cc=dgilbert@interlog.com \ --cc=dm-devel@redhat.com \ --cc=fbui@suse.de \ --cc=hare@suse.de \ --cc=jejb@linux.vnet.ibm.com \ --cc=linux-scsi@vger.kernel.org \ --cc=martin.petersen@oracle.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.