summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Truschnigg <jtru@users.noreply.github.com>2016-12-02 18:30:40 +0100
committerBrian Coca <bcoca@users.noreply.github.com>2016-12-02 12:30:40 -0500
commitb377301195e7d7720551538a33d2499eee1a1d30 (patch)
tree4024ee1d232b5bddb7cdd2aea789f9cbc58a1466
parent819c51cd807061845ad5db9c5aaa8e05a623939b (diff)
downloadansible-stable-1.9.tar.gz
Fix sizes reported for devices with phys. bs != 512b (#15521)stable-1.9
The `setup` module reports incorrectly computed disk and partition size facts on (afaict) all Linux kernels for block devices that report a physical block size other than 512b. This happens because `facts.py` incorrectly assumes that sysfs reports a device's block count in units of that device's physical sector size. The kernel, however, always reports and exports sector counts in units of 512b sectors, even if the device's hardware interface cannot address individual blocks this small. The results we see are inflated capacity figures for things like some SSD models and 4kn-HDDs that do report a hardware sector size greater than 512b.
-rw-r--r--lib/ansible/module_utils/facts.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
index a8f67582d4..36c6a6aa1f 100644
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -969,7 +969,7 @@ class LinuxHardware(Hardware):
part['sectorsize'] = get_file_content(part_sysdir + "/queue/physical_block_size")
if not part['sectorsize']:
part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size",512)
- part['size'] = module.pretty_bytes((float(part['sectors']) * float(part['sectorsize'])))
+ part['size'] = module.pretty_bytes((float(part['sectors']) * 512))
d['partitions'][partname] = part
d['rotational'] = get_file_content(sysdir + "/queue/rotational")
@@ -986,7 +986,7 @@ class LinuxHardware(Hardware):
d['sectorsize'] = get_file_content(sysdir + "/queue/physical_block_size")
if not d['sectorsize']:
d['sectorsize'] = get_file_content(sysdir + "/queue/hw_sector_size",512)
- d['size'] = module.pretty_bytes(float(d['sectors']) * float(d['sectorsize']))
+ d['size'] = module.pretty_bytes(float(d['sectors']) * 512)
d['host'] = ""