Skip to content
This repository
Browse code

Low: iSCSILogicalUnit: add lio_iblock parameter.

When having multiple LUNs using the same iblock device, 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.
  • Loading branch information...
commit 8bbc2663859bb3d3b35c3342ba3d49b3de1d7da6 1 parent ddad46c
JOJ0 JOJ0 authored

Showing 1 changed file with 22 additions and 6 deletions. Show diff stats Hide diff stats

  1. +22 6 heartbeat/iSCSILogicalUnit
28 heartbeat/iSCSILogicalUnit
@@ -56,6 +56,9 @@ OCF_RESKEY_scsi_id_default="${OCF_RESOURCE_INSTANCE:0:16}"
56 56 sn=`echo -n "${OCF_RESOURCE_INSTANCE}" | openssl md5 | sed -e 's/(stdin)= //'`
57 57 OCF_RESKEY_scsi_sn_default=${sn:0:8}
58 58 : ${OCF_RESKEY_scsi_sn=${OCF_RESKEY_scsi_sn_default}}
  59 +# set 0 as a default value for lio iblock device number
  60 +OCF_RESKEY_lio_iblock_default=0
  61 +OCF_RESKEY_lio_iblock=${OCF_RESKEY_lio_iblock:-$OCF_RESKEY_lio_iblock_default}
59 62 #######################################################################
60 63
61 64 meta_data() {
@@ -168,6 +171,19 @@ to this lun.</shortdesc>
168 171 <content type="string" default=""/>
169 172 </parameter>
170 173
  174 +<parameter name="lio_iblock" required="0" unique="0">
  175 +<longdesc lang="en">
  176 +LIO iblock device name, a number starting from 0.
  177 +
  178 +Using distinct values here avoids a warning in LIO "LEGACY: SHARED HBA";
  179 +and it is necessary when using multiple LUNs started at the same time
  180 +(eg. on node failover) to prevent a race condition in tcm_core on mkdir()
  181 +in /sys/kernel/config/target/core/.
  182 +</longdesc>
  183 +<shortdesc lang="en">LIO iblock device number</shortdesc>
  184 +<content type="integer" default="0"/>
  185 +</parameter>
  186 +
171 187 </parameters>
172 188
173 189 <actions>
@@ -252,14 +268,14 @@ iSCSILogicalUnit_start() {
252 268 lio)
253 269 # For lio, we first have to create a target device, then
254 270 # add it to the Target Portal Group as an LU.
255   - ocf_run tcm_node --createdev=iblock_0/${OCF_RESOURCE_INSTANCE} \
  271 + ocf_run tcm_node --createdev=iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE} \
256 272 ${OCF_RESKEY_path} || exit $OCF_ERR_GENERIC
257 273 if [ -n "${OCF_RESKEY_scsi_sn}" ]; then
258   - ocf_run tcm_node --setunitserial=iblock_0/${OCF_RESOURCE_INSTANCE} \
  274 + ocf_run tcm_node --setunitserial=iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE} \
259 275 ${OCF_RESKEY_scsi_sn} || exit $OCF_ERR_GENERIC
260 276 fi
261 277 ocf_run lio_node --addlun=${OCF_RESKEY_target_iqn} 1 ${OCF_RESKEY_lun} \
262   - ${OCF_RESOURCE_INSTANCE} iblock_0/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
  278 + ${OCF_RESOURCE_INSTANCE} iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
263 279
264 280 if [ -n "${OCF_RESKEY_allowed_initiators}" ]; then
265 281 for initiator in ${OCF_RESKEY_allowed_initiators}; do
@@ -304,7 +320,7 @@ iSCSILogicalUnit_stop() {
304 320 done
305 321 fi
306 322 ocf_run lio_node --dellun=${OCF_RESKEY_target_iqn} 1 ${OCF_RESKEY_lun} || exit $OCF_ERR_GENERIC
307   - ocf_run tcm_node --freedev=iblock_0/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
  323 + ocf_run tcm_node --freedev=iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
308 324 esac
309 325 fi
310 326
@@ -423,10 +439,10 @@ iSCSILogicalUnit_validate() {
423 439 iet)
424 440 # IET does not support setting the vendor and product ID
425 441 # (it always uses "IET" and "VIRTUAL-DISK")
426   - unsupported_params="vendor_id product_id allowed_initiators"
  442 + unsupported_params="vendor_id product_id allowed_initiators lio_iblock"
427 443 ;;
428 444 tgt)
429   - unsupported_params="allowed_initiators"
  445 + unsupported_params="allowed_initiators lio_iblock"
430 446 ;;
431 447 lio)
432 448 unsupported_params="scsi_id vendor_id product_id"

0 comments on commit 8bbc266

Please sign in to comment.
Something went wrong with that request. Please try again.