From 3b1334c4e268a585912d0e177c76af61f6b8099c Mon Sep 17 00:00:00 2001 From: Brano Zarnovican Date: Mon, 4 Feb 2013 13:39:44 +0100 Subject: [PATCH] BUGFIX: #1112483 - device size mismatch when LUN is reused if the iSCSI session cannot be closed (because there are other LUNs still in use), we will remove selectively only the SCSI device corresponding to the volume which is being disconnected. If the same LUN id will be reused later, next connect_volume() call will notice that the local device is missing and force --rescan. --- nova/rootwrap/compute.py | 1 + nova/virt/libvirt/volume.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/nova/rootwrap/compute.py b/nova/rootwrap/compute.py index d28d3a0..b3a3cbc 100755 --- a/nova/rootwrap/compute.py +++ b/nova/rootwrap/compute.py @@ -74,6 +74,7 @@ filterlist = [ filters.CommandFilter("/bin/chmod", "root"), # nova/virt/disk/api.py: 'cp', os.path.join(fs... + # nova/virt/libvirt/volume.py: echo 1 | cp /dev/stdin /sys/block/.. filters.CommandFilter("/bin/cp", "root"), # nova/virt/libvirt/vif.py: 'ip', 'tuntap', 'add', dev, 'mode', 'tap' diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py index 2edfa1b..ffd5379 100644 --- a/nova/virt/libvirt/volume.py +++ b/nova/virt/libvirt/volume.py @@ -208,3 +208,14 @@ class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver): check_exit_code=[0, 255]) self._run_iscsiadm(iscsi_properties, ('--op', 'delete'), check_exit_code=[0, 255]) + else: + # can't close the session, at least delete the device for disconnected vol + if not 'target_lun' in iscsi_properties: + return + host_device = device_prefix+str(iscsi_properties['target_lun']) + device_shortname = os.path.basename(os.path.realpath(host_device)) + delete_ctl_file = '/sys/block/'+device_shortname+'/device/delete' + if os.path.exists(delete_ctl_file): + # echo 1 > /sys/block/sdX/device/delete + utils.execute('cp', '/dev/stdin', delete_ctl_file, + process_input='1', run_as_root=True) -- 1.7.11.7