From 22f4486e8a5163dae7eb57187adfacdc826caec7 Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Thu, 2 Sep 2021 22:23:24 -0600 Subject: [PATCH] fix controller expand volume logic for SCALE Signed-off-by: Travis Glenn Hansen --- src/driver/freenas/ssh.js | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/driver/freenas/ssh.js b/src/driver/freenas/ssh.js index 605b873..c88c101 100644 --- a/src/driver/freenas/ssh.js +++ b/src/driver/freenas/ssh.js @@ -201,9 +201,8 @@ class FreeNASSshDriver extends ControllerZfsSshBaseDriver { share = { nfs_paths: [properties.mountpoint.value], nfs_comment: `democratic-csi (${this.ctx.args.csiName}): ${datasetName}`, - nfs_network: this.options.nfs.shareAllowedNetworks.join( - "," - ), + nfs_network: + this.options.nfs.shareAllowedNetworks.join(","), nfs_hosts: this.options.nfs.shareAllowedHosts.join(","), nfs_alldirs: this.options.nfs.shareAlldirs, nfs_ro: false, @@ -633,11 +632,10 @@ class FreeNASSshDriver extends ControllerZfsSshBaseDriver { ? this.options.iscsi.extentBlocksize : 512; - const extentDisablePhysicalBlocksize = this.options.iscsi.hasOwnProperty( - "extentDisablePhysicalBlocksize" - ) - ? this.options.iscsi.extentDisablePhysicalBlocksize - : true; + const extentDisablePhysicalBlocksize = + this.options.iscsi.hasOwnProperty("extentDisablePhysicalBlocksize") + ? this.options.iscsi.extentDisablePhysicalBlocksize + : true; const extentRpm = this.options.iscsi.hasOwnProperty("extentRpm") ? this.options.iscsi.extentRpm @@ -1605,6 +1603,7 @@ class FreeNASSshDriver extends ControllerZfsSshBaseDriver { async expandVolume(call, datasetName) { const driverShareType = this.getDriverShareType(); const sshClient = this.getSshClient(); + const zb = await this.getZetabyte(); switch (driverShareType) { case "iscsi": @@ -1612,7 +1611,29 @@ class FreeNASSshDriver extends ControllerZfsSshBaseDriver { let command; let reload = false; if (isScale) { - command = sshClient.buildCommand("systemctl", ["reload", "scst"]); + let properties; + properties = await zb.zfs.get(datasetName, [ + FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME, + ]); + properties = properties[datasetName]; + this.ctx.logger.debug("zfs props data: %j", properties); + let iscsiName = + properties[FREENAS_ISCSI_ASSETS_NAME_PROPERTY_NAME].value; + + /** + * command = sshClient.buildCommand("systemctl", ["reload", "scst"]); + * does not help ^ + * + * echo 1 > /sys/kernel/scst_tgt/devices/${iscsiName}/resync_size + * works ^ + * + * scstadmin -resync_dev ${iscsiName} + * works but always give a exit code of 1 ^ + */ + command = sshClient.buildCommand("sh", [ + "-c", + `echo 1 > /sys/kernel/scst_tgt/devices/${iscsiName}/resync_size`, + ]); reload = true; } else { command = sshClient.buildCommand("/etc/rc.d/ctld", ["reload"]);