From 411101f366ea3581be380c580903432bddac08dd Mon Sep 17 00:00:00 2001 From: Arnon Yaari Date: Mon, 7 Nov 2016 17:56:40 +0200 Subject: [PATCH 1/2] STORAGEMODEL-376 read host number in hctl from sd devices with a sepaate ioctl --- src/infi/sgutils/ioctl/__init__.py | 7 +++++++ src/infi/sgutils/ioctl/opcodes/__init__.py | 1 + src/infi/sgutils/sg_map/__init__.py | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/infi/sgutils/ioctl/__init__.py b/src/infi/sgutils/ioctl/__init__.py index 9d37cd8..f164a73 100644 --- a/src/infi/sgutils/ioctl/__init__.py +++ b/src/infi/sgutils/ioctl/__init__.py @@ -32,3 +32,10 @@ def scsi_ioctl_get_idlun(device_path): result = ioctl(device_path, opcodes.SCSI_IOCTL_GET_IDLUN, buffer) struct = struct_cls.create_from_string(buffer) return struct + +def scsi_ioctl_get_bus_number(device_path): + """:returns: a :class:`.SG_GET_SCSI_ID` object""" + from ctypes import c_ulong + buffer = c_ulong() + result = ioctl(device_path, opcodes.SCSI_IOCTL_GET_BUS_NUMBER, buffer) + return buffer.value diff --git a/src/infi/sgutils/ioctl/opcodes/__init__.py b/src/infi/sgutils/ioctl/opcodes/__init__.py index 372b4b2..611a4e0 100644 --- a/src/infi/sgutils/ioctl/opcodes/__init__.py +++ b/src/infi/sgutils/ioctl/opcodes/__init__.py @@ -1,4 +1,5 @@ SG_GET_SCSI_ID = 0x2276 SCSI_IOCTL_GET_IDLUN = 0x5382 +SCSI_IOCTL_GET_BUS_NUMBER = 0x5386 diff --git a/src/infi/sgutils/sg_map/__init__.py b/src/infi/sgutils/sg_map/__init__.py index 936db5e..904c6a0 100644 --- a/src/infi/sgutils/sg_map/__init__.py +++ b/src/infi/sgutils/sg_map/__init__.py @@ -6,8 +6,8 @@ def get_hctl_for_sg_device(device_path): return HCTL(struct.host_no, struct.channel, struct.scsi_id, struct.lun) def get_hctl_for_sd_device(device_path): - from ..ioctl import scsi_ioctl_get_idlun as _ioctl - struct = _ioctl(device_path) + from ..ioctl import scsi_ioctl_get_idlun, scsi_ioctl_get_bus_number + struct = scsi_ioctl_get_idlun(device_path) # http://tldp.org/HOWTO/SCSI-Generic-HOWTO/scsi_g_idlun.html # "four_in_one" is made up as follows: # (scsi_device_id | (lun << 8) | (channel << 16) | (host_no << 24)) @@ -16,6 +16,8 @@ def get_hctl_for_sd_device(device_path): target = (struct.four_in_one) & 0xFF lun = (struct.four_in_one >> 8) & 0xFF result = HCTL(host, channel, target, lun) + # STORAGEMODEL-376: re-read host number with a ioctl that doesn't limit the value to 255 + host = scsi_ioctl_get_bus_number(device_path) return HCTL(host, channel, target, lun) def get_sg_to_hctl_mappings(): From 98b16cb406097b7fbcf238d666d9f192cb41c5c4 Mon Sep 17 00:00:00 2001 From: Arnon Yaari Date: Mon, 7 Nov 2016 18:00:44 +0200 Subject: [PATCH 2/2] update buildout.cfg --- buildout.cfg | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/buildout.cfg b/buildout.cfg index 57b9987..a12f00c 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -26,7 +26,7 @@ pre_uninstall_script_name = None [isolated-python] recipe = infi.recipe.python -version = v2.7.6.21 +version = v2.7.8.5 [setup.py] recipe = infi.recipe.template.version @@ -36,17 +36,6 @@ output = setup.py [__version__.py] recipe = infi.recipe.template.version output = ${project:version_file} -input = inline: - __version__ = "${infi.recipe.template.version:version}" - __git_commiter_name__ = "${infi.recipe.template.version:author}" - __git_commiter_email__ = "${infi.recipe.template.version:author_email}" - __git_branch__ = ${infi.recipe.template.version:git_local_branch} - __git_remote_tracking_branch__ = ${infi.recipe.template.version:git_remote_tracking_branch} - __git_remote_url__ = ${infi.recipe.template.version:git_remote_url} - __git_head_hash__ = ${infi.recipe.template.version:head_hash} - __git_head_subject__ = ${infi.recipe.template.version:head_subject} - __git_head_message__ = ${infi.recipe.template.version:head_message} - __git_dirty_diff__ = ${infi.recipe.template.version:dirty_diff} [development-scripts] dependent-scripts = true @@ -54,24 +43,11 @@ recipe = infi.recipe.console_scripts eggs = ${project:name} ipython nose - mock coverage - pylint infi.unittest infi.traceback interpreter = python -[eclipse] -recipe = rbco.recipe.pyeclipse -project-name = ${project:name} -project-directory = ${buildout:directory} -python-version = 2.7 -source-resources = ${buildout:directory}/src - -[pydev] -recipe = pb.recipes.pydev -eggs = ${development-scripts:eggs} - [pack] recipe = infi.recipe.application_packager