The iSCSILogicalUnit lio-t is not operational with targetcli 3.x

I have made the following adjustments for a few years now that mostly resolved the issue, but failovers where not solid. When looking into this again, I noticed the version on github had been updated to include some locking behavior, and when that was added long with the changes I made to make it targetcli 3.x compatable, I haven't had any issues since.

Attached is the patch. Mainly I wanted to know the best why you would want to commit it. As I believe you wouldn't take it as is, since it removed targetcli <3.x support. Should it detect what version of targetcli is being used on the system? Should it be a new section, like lio-t3, or another method.

I also have issues with the new behavior that was added lately to it, that adds an ipv6 ip address to the iscsi target group. I don't understand why this code is in the LogicalUnit setup, and not in the iSCSITarget code, and also why it's even in there at all. This completely breaks my IP config in my iSCSITarget config, it has no checks to see what was configured but just blanket changes the config of the target everytime a lun is added to that target. It only checks if ipv6 is active, and if so adds it. It doesn't even bother to check if ipv6 is enabled on the target interface or anything, just anywhere on the system (localhost, only link scope). This can be done, but should ONLY be done in iSCSITarget, if no binding IP address was defined.


--- iSCSILogicalUnit    2017-12-17 08:44:52.187159088 -0500
+++ ../../../iSCSILogicalUnit   2017-12-17 09:14:19.383127946 -0500
@@ -402,19 +402,25 @@
        lio-t)
                ocf_take_lock $TARGETLOCKFILE
                ocf_release_lock_on_exit $TARGETLOCKFILE
-               
iblock_attrib_path="/sys/kernel/config/target/core/iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE}/attrib"
                # For lio, we first have to create a target device, then
                # add it to the Target Portal Group as an LU.
-               ocf_run targetcli /backstores/block create 
name=${OCF_RESOURCE_INSTANCE} dev=${OCF_RESKEY_path} || exit $OCF_ERR_GENERIC
+               wwn=""
                if [ -n "${OCF_RESKEY_scsi_sn}" ]; then
-                       echo ${OCF_RESKEY_scsi_sn} > 
/sys/kernel/config/target/core/iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE}/wwn/vpd_unit_serial
+                       wwn="wwn=${OCF_RESKEY_scsi_sn} "
                fi
-               ocf_run targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/luns 
create /backstores/block/${OCF_RESOURCE_INSTANCE} ${OCF_RESKEY_lun} || exit 
$OCF_ERR_GENERIC
+               ocf_run targetcli /backstores/iblock create 
name=${OCF_RESOURCE_INSTANCE} dev=${OCF_RESKEY_path} ${wwn} || exit 
$OCF_ERR_GENERIC
 
-               if $(ip a | grep -q inet6); then
-                       ocf_run -q targetcli 
/iscsi/${OCF_RESKEY_target_iqn}/tpg1/portals delete 0.0.0.0 3260
-                       ocf_run -q targetcli 
/iscsi/${OCF_RESKEY_target_iqn}/tpg1/portals create ::0
+               if [ -n "${OCF_RESKEY_emulate_tpu}" ]; then
+                       ocf_run targetcli 
/backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_tpu=1
+               fi
+               if [ -n "${OCF_RESKEY_emulate_3pc}" ]; then
+                       ocf_run targetcli 
/backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_3pc=1
                fi
+               if [ -n "${OCF_RESKEY_emulate_caw}" ]; then
+                       ocf_run targetcli 
/backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_caw=1
+               fi
+
+               ocf_run targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/luns 
create /backstores/iblock/${OCF_RESOURCE_INSTANCE} ${OCF_RESKEY_lun} || exit 
$OCF_ERR_GENERIC
 
                if [ -n "${OCF_RESKEY_allowed_initiators}" ]; then
                        for initiator in ${OCF_RESKEY_allowed_initiators}; do
@@ -423,15 +429,6 @@
                        done
                fi
 
-               if [ -n "${OCF_RESKEY_emulate_tpu}" ]; then
-                       echo ${OCF_RESKEY_emulate_tpu} > 
${iblock_attrib_path}/emulate_tpu || exit $OCF_ERR_GENERIC
-               fi
-               if [ -n "${OCF_RESKEY_emulate_3pc}" ]; then
-                       echo ${OCF_RESKEY_emulate_3pc} > 
${iblock_attrib_path}/emulate_3pc || exit $OCF_ERR_GENERIC
-               fi
-               if [ -n "${OCF_RESKEY_emulate_caw}" ]; then
-                       echo ${OCF_RESKEY_emulate_caw} > 
${iblock_attrib_path}/emulate_caw || exit $OCF_ERR_GENERIC
-               fi
                ;;
        esac
 
@@ -504,7 +501,7 @@
                # delete the backstore, then something is seriously
                # wrong and we need to fail the stop operation
                # (potentially causing fencing)
-               ocf_run targetcli /backstores/block delete 
${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
+               ocf_run targetcli /backstores/iblock delete 
${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
                ;;
        esac
 
_______________________________________________
Developers mailing list
[email protected]
http://lists.clusterlabs.org/mailman/listinfo/developers

Reply via email to