Change in vdsm[master]: resize-lun: Rescan fiber channel devices
nsoffer at redhat.com
nsoffer at redhat.com
Mon Jul 13 08:22:22 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: resize-lun: Rescan fiber channel devices
......................................................................
Patch Set 3: -Code-Review
(1 comment)
The glob pattern is too fragile, we need to use more robust way to find devices.
https://gerrit.ovirt.org/#/c/43388/3/vdsm/storage/fc-scan
File vdsm/storage/fc-scan:
Line 93: """
Line 94: Scans host's devices in order to detect changes in devices size
Line 95: """
Line 96: rescan_pattern = ("/sys/devices/*/*/*/%s/rport-*/target*/*/"
Line 97: "scsi_device/*/device/rescan" % self.host)
This pattern is little fragile - if the kernel will change the internals, it may stop working.
I think we should replace it with something like:
1. Get real path of the host
>>> os.path.realpath("/sys/class/fc_host/host5/../..")
'/sys/devices/pci0000:00/0000:00:04.0/0000:07:00.0/host5'
Now we eliminated breakage of the first part of this pattern
2. Find the devices of this host:
>>> for device_path in glob.glob("/sys/block/sd*"):
... real_device_path = os.path.realpath(device_path)
... if real_device_path.startswith(host_path):
... print real_device_path
...
/sys/devices/pci0000:00/0000:00:04.0/0000:07:00.0/host5/rport-5:0-0/target5:0:0/5:0:0:0/block/sdc
/sys/devices/pci0000:00/0000:00:04.0/0000:07:00.0/host5/rport-5:0-0/target5:0:0/5:0:0:1/block/sdd
...
This code should be separated to a helper function such as find_host_devices
Now we eliminated the breakage of the second part (rport, target) of the pattern.
3. build the rescan path from the found devices
>>> os.path.realpath(device_path + "/../../rescan")
'/sys/devices/pci0000:00/0000:00:04.0/0000:07:00.1/host6/rport-6:0-1/target6:0:1/6:0:1:7/rescan'
Note that the path used in this patch is a symlink to the real rescan path:
>>> os.path.realpath(device_path + "/../../scsi_device/6:0:1:7/device/rescan")
'/sys/devices/pci0000:00/0000:00:04.0/0000:07:00.1/host6/rport-6:0-1/target6:0:1/6:0:1:7/rescan'
Line 98: for path in glob.glob(rescan_pattern):
Line 99: try:
Line 100: log.debug("Rescanning device %s", path)
Line 101: with utils.stopwatch("Rescanned device %s" % path, log=log):
--
To view, visit https://gerrit.ovirt.org/43388
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I201312c44fec30d11ad62823558aa10ad7f7991b
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland at redhat.com>
Gerrit-Reviewer: Freddy Rolland <frolland at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list