Hi Florian, Dejan told me that you're the maintainer for the iSCSI pieces, so I'm sending you this patch.
Please apply, thank you very much! Regards, Phil -- : Ing. Philipp Marek : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com : DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
From 304c4fadad89ad0467e42b0b29c3c62a4ee99aee Mon Sep 17 00:00:00 2001 From: Philipp Marek <philipp.ma...@linbit.com> Date: Mon, 8 Oct 2012 13:38:41 +0200 Subject: [PATCH] Medium: Fix race condition in iSCSILogicalUnit. When having multiple LUNs in the same iblock definition, and they're started simultaneously, the tcm_core script might see a race condition on mkdir() for the "/sys/kernel/config/target/core/iblock_0" directory, preventing at least one instance from starting. Make the iblock ID configurable to avoid the name clash. --- heartbeat/iSCSILogicalUnit | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git heartbeat/iSCSILogicalUnit heartbeat/iSCSILogicalUnit index b55ccd0..d5b4b56 100755 --- heartbeat/iSCSILogicalUnit +++ heartbeat/iSCSILogicalUnit @@ -56,6 +56,9 @@ OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE:0:16}" sn=`echo -n "${OCF_RESOURCE_INSTANCE}" | openssl md5 | sed -e 's/(stdin)= //'` OCF_RESKEY_scsi_sn_default=${sn:0:8} : ${OCF_RESKEY_scsi_sn=${OCF_RESKEY_scsi_sn_default}} +# default value for iblock +OCF_RESKEY_iblock_default=0 +OCF_RESKEY_iblock=iblock_${OCF_RESKEY_iblock:-$OCF_RESKEY_iblock_default} ####################################################################### meta_data() { @@ -168,6 +171,19 @@ to this lun.</shortdesc> <content type="string" default=""/> </parameter> +<parameter name="iblock" required="0" unique="0"> +<longdesc lang="en"> +iblock device name, a number starting from 0. + +Using distinct values here avoids a warning in LIO "LEGACY: SHARED HBA"; +and it is necessary when using multiple LUNs started at the same time +(eg. on node failover) to prevent a race condition in tcm_core on mkdir() +in /sys/kernel/config/target/core/. +</longdesc> +<shortdesc lang="en">iblock device number</shortdesc> +<content type="integer" default="0"/> +</parameter> + </parameters> <actions> @@ -252,14 +268,14 @@ iSCSILogicalUnit_start() { lio) # For lio, we first have to create a target device, then # add it to the Target Portal Group as an LU. - ocf_run tcm_node --createdev=iblock_0/${OCF_RESOURCE_INSTANCE} \ + ocf_run tcm_node --createdev=${OCF_RESKEY_iblock}/${OCF_RESOURCE_INSTANCE} \ ${OCF_RESKEY_path} || exit $OCF_ERR_GENERIC if [ -n "${OCF_RESKEY_scsi_sn}" ]; then - ocf_run tcm_node --setunitserial=iblock_0/${OCF_RESOURCE_INSTANCE} \ + ocf_run tcm_node --setunitserial=${OCF_RESKEY_iblock}/${OCF_RESOURCE_INSTANCE} \ ${OCF_RESKEY_scsi_sn} || exit $OCF_ERR_GENERIC fi ocf_run lio_node --addlun=${OCF_RESKEY_target_iqn} 1 ${OCF_RESKEY_lun} \ - ${OCF_RESOURCE_INSTANCE} iblock_0/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC + ${OCF_RESOURCE_INSTANCE} ${OCF_RESKEY_iblock}/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC if [ -n "${OCF_RESKEY_allowed_initiators}" ]; then for initiator in ${OCF_RESKEY_allowed_initiators}; do @@ -304,7 +320,7 @@ iSCSILogicalUnit_stop() { done fi ocf_run lio_node --dellun=${OCF_RESKEY_target_iqn} 1 ${OCF_RESKEY_lun} || exit $OCF_ERR_GENERIC - ocf_run tcm_node --freedev=iblock_0/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC + ocf_run tcm_node --freedev=${OCF_RESKEY_iblock}/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC esac fi -- 1.7.10.4
_______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/