Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev

[PATCH] RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 bytes

 

 

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded


florian.haas at linbit

Jul 10, 2009, 12:19 AM

Post #1 of 2 (711 views)
Permalink
[PATCH] RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 bytes

# HG changeset patch
# User Florian Haas <florian.haas [at] linbit>
# Date 1247210329 -7200
# Node ID 2057096e00c6f34f4dc561d4c9d4984356f699ca
# Parent 23b5683b1ce522a085e33e9439b67a97e3556c79
RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 bytes

SCSI IDs are limited to 24 bytes, thus if $OCF_RESOURCE_INSTANCE is
longer than that, truncate it for $OCF_RESKEY_scsi_id_default.

Also, set a cluster-wide unique, failover persistent default for the
SCSI serial number. I choose the first 8 bytes of an MD5 hash of
$OCF_RESOURCE_INSTANCE. SCSI SNs can actually be up to 16 bytes long,
but 8 bytes should be sufficient to provide uniqueness.

All of this, of course, is to ensure smooth failover for iSCSI
initiators that read the SCSI ID and SN upon reconnect after a
connection interruption.

diff -r 23b5683b1ce5 -r 2057096e00c6 resources/OCF/iSCSILogicalUnit
--- a/resources/OCF/iSCSILogicalUnit Thu Jul 09 13:05:24 2009 +0200
+++ b/resources/OCF/iSCSILogicalUnit Fri Jul 10 09:18:49 2009 +0200
@@ -41,10 +41,17 @@
fi
: ${OCF_RESKEY_implementation=${OCF_RESKEY_implementation_default}}

-# Use a default SCSI ID that is unique across the cluster, and
-# persistent in the event of resource migration
-OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE}"
+# Use a default SCSI ID and SCSI SN that is unique across the cluster,
+# and persistent in the event of resource migration
+# SCSI IDs are limited to 24 bytes, so take the first 24 bytes of
+# $OCF_RESOURCE_INSTANCE
+OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE:0:24}"
: ${OCF_RESKEY_scsi_id=${OCF_RESKEY_scsi_id_default}}
+# To have a reasonably unique default SCSI SN, use the first 8 bytes
+# of an MD5 hash of of $OCF_RESOURCE_INSTANCE
+sn=`echo -n "${OCF_RESOURCE_INSTANCE}" | openssl md5`
+OCF_RESKEY_scsi_sn_default=${sn:0:8}
+: ${OCF_RESKEY_scsi_sn=${OCF_RESKEY_scsi_sn_default}}
#######################################################################

meta_data() {
@@ -99,7 +106,8 @@

<parameter name="scsi_id" required="0" unique="0">
<longdesc lang="en">
-The SCSI ID to be configured for this Logical Unit.
+The SCSI ID to be configured for this Logical Unit. The default
+is the resource name, truncated to 24 bytes.
</longdesc>
<shortdesc lang="en">SCSI ID</shortdesc>
<content type="string" default="${OCF_RESKEY_scsi_id_default}"/>
@@ -108,9 +116,10 @@
<parameter name="scsi_sn" required="0" unique="0">
<longdesc lang="en">
The SCSI serial number to be configured for this Logical Unit.
+The default is a hash of the resource name, truncated to 8 bytes.
</longdesc>
<shortdesc lang="en">SCSI serial number</shortdesc>
-<content type="string" />
+<content type="string" default="${OCF_RESKEY_scsi_sn_default}"/>
</parameter>

<parameter name="vendor_id" required="0" unique="0">
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


dejanmm at fastmail

Jul 10, 2009, 4:33 AM

Post #2 of 2 (645 views)
Permalink
Re: [PATCH] RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 bytes [In reply to]

Applied.

Thanks,

Dejan

On Fri, Jul 10, 2009 at 09:19:04AM +0200, Florian Haas wrote:
> # HG changeset patch
> # User Florian Haas <florian.haas [at] linbit>
> # Date 1247210329 -7200
> # Node ID 2057096e00c6f34f4dc561d4c9d4984356f699ca
> # Parent 23b5683b1ce522a085e33e9439b67a97e3556c79
> RA: iSCSILogicalUnit: set default for SCSI SN, truncate SCSI ID default to 24 bytes
>
> SCSI IDs are limited to 24 bytes, thus if $OCF_RESOURCE_INSTANCE is
> longer than that, truncate it for $OCF_RESKEY_scsi_id_default.
>
> Also, set a cluster-wide unique, failover persistent default for the
> SCSI serial number. I choose the first 8 bytes of an MD5 hash of
> $OCF_RESOURCE_INSTANCE. SCSI SNs can actually be up to 16 bytes long,
> but 8 bytes should be sufficient to provide uniqueness.
>
> All of this, of course, is to ensure smooth failover for iSCSI
> initiators that read the SCSI ID and SN upon reconnect after a
> connection interruption.
>
> diff -r 23b5683b1ce5 -r 2057096e00c6 resources/OCF/iSCSILogicalUnit
> --- a/resources/OCF/iSCSILogicalUnit Thu Jul 09 13:05:24 2009 +0200
> +++ b/resources/OCF/iSCSILogicalUnit Fri Jul 10 09:18:49 2009 +0200
> @@ -41,10 +41,17 @@
> fi
> : ${OCF_RESKEY_implementation=${OCF_RESKEY_implementation_default}}
>
> -# Use a default SCSI ID that is unique across the cluster, and
> -# persistent in the event of resource migration
> -OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE}"
> +# Use a default SCSI ID and SCSI SN that is unique across the cluster,
> +# and persistent in the event of resource migration
> +# SCSI IDs are limited to 24 bytes, so take the first 24 bytes of
> +# $OCF_RESOURCE_INSTANCE
> +OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE:0:24}"
> : ${OCF_RESKEY_scsi_id=${OCF_RESKEY_scsi_id_default}}
> +# To have a reasonably unique default SCSI SN, use the first 8 bytes
> +# of an MD5 hash of of $OCF_RESOURCE_INSTANCE
> +sn=`echo -n "${OCF_RESOURCE_INSTANCE}" | openssl md5`
> +OCF_RESKEY_scsi_sn_default=${sn:0:8}
> +: ${OCF_RESKEY_scsi_sn=${OCF_RESKEY_scsi_sn_default}}
> #######################################################################
>
> meta_data() {
> @@ -99,7 +106,8 @@
>
> <parameter name="scsi_id" required="0" unique="0">
> <longdesc lang="en">
> -The SCSI ID to be configured for this Logical Unit.
> +The SCSI ID to be configured for this Logical Unit. The default
> +is the resource name, truncated to 24 bytes.
> </longdesc>
> <shortdesc lang="en">SCSI ID</shortdesc>
> <content type="string" default="${OCF_RESKEY_scsi_id_default}"/>
> @@ -108,9 +116,10 @@
> <parameter name="scsi_sn" required="0" unique="0">
> <longdesc lang="en">
> The SCSI serial number to be configured for this Logical Unit.
> +The default is a hash of the resource name, truncated to 8 bytes.
> </longdesc>
> <shortdesc lang="en">SCSI serial number</shortdesc>
> -<content type="string" />
> +<content type="string" default="${OCF_RESKEY_scsi_sn_default}"/>
> </parameter>
>
> <parameter name="vendor_id" required="0" unique="0">
> _______________________________________________________
> Linux-HA-Dev: Linux-HA-Dev [at] lists
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.