diff --git a/examples/zfs-generic-iscsi.yaml b/examples/zfs-generic-iscsi.yaml index 2aaf5d0..af5df37 100644 --- a/examples/zfs-generic-iscsi.yaml +++ b/examples/zfs-generic-iscsi.yaml @@ -70,7 +70,11 @@ iscsi: #password: "bar" # mutual CHAP #mutual_userid: "baz" - #mutual_password: "bar" + #mutual_password: "bar" + block: + attributes: + # set to 1 to enable Thin Provisioning Unmap + emulate_tpu: 0 targetPortal: "server[:port]" # for multipath targetPortals: [] # [ "server[:port]", "server[:port]", ... ] diff --git a/src/driver/controller-zfs-generic/index.js b/src/driver/controller-zfs-generic/index.js index 6ba5b0b..d3080ae 100644 --- a/src/driver/controller-zfs-generic/index.js +++ b/src/driver/controller-zfs-generic/index.js @@ -219,6 +219,22 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { basename = this.options.iscsi.shareStrategyTargetCli.basename; let setAttributesText = ""; let setAuthText = ""; + let setBlockAttributesText = ""; + + if (this.options.iscsi.shareStrategyTargetCli.block) { + if (this.options.iscsi.shareStrategyTargetCli.block.attributes) { + for (const attributeName in this.options.iscsi + .shareStrategyTargetCli.block.attributes) { + const attributeValue = + this.options.iscsi.shareStrategyTargetCli.block.attributes[ + attributeName + ]; + setBlockAttributesText += "\n"; + setBlockAttributesText += `set attribute ${attributeName}=${attributeValue}`; + } + } + } + if (this.options.iscsi.shareStrategyTargetCli.tpg) { if (this.options.iscsi.shareStrategyTargetCli.tpg.attributes) { for (const attributeName in this.options.iscsi @@ -263,6 +279,8 @@ ${setAuthText} # create extent cd /backstores/block create ${assetName} /dev/${extentDiskName} +cd /backstores/block/${assetName} +${setBlockAttributesText} # add extent to target/tpg cd /iscsi/${basename}:${assetName}/tpg1/luns