From 00d75ff4495c111ee4e4ebd4283cb45c362fdd75 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Mon, 8 Jan 2018 15:18:25 +0100 Subject: [PATCH] Fix Linux blockdevice size computation (#34475) Linux' sysfs _always_ reports device size in 512b sector units, regardless of the device's actual, physical blocksize. --- lib/ansible/module_utils/facts/hardware/linux.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index 32fc1c0a4cf..71b8d1eefe2 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -601,7 +601,7 @@ class LinuxHardware(Hardware): part['sectorsize'] = get_file_content(part_sysdir + "/queue/logical_block_size") if not part['sectorsize']: part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size", 512) - part['size'] = bytes_to_human((float(part['sectors']) * float(part['sectorsize']))) + part['size'] = bytes_to_human((float(part['sectors']) * 512.0)) part['uuid'] = get_partition_uuid(partname) self.get_holders(part, part_sysdir) @@ -621,7 +621,7 @@ class LinuxHardware(Hardware): d['sectorsize'] = get_file_content(sysdir + "/queue/logical_block_size") if not d['sectorsize']: d['sectorsize'] = get_file_content(sysdir + "/queue/hw_sector_size", 512) - d['size'] = bytes_to_human(float(d['sectors']) * float(d['sectorsize'])) + d['size'] = bytes_to_human(float(d['sectors']) * 512.0) d['host'] = ""