Fix sizes reported for devices with phys. bs != 512b (#15521)

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.
This commit is contained in:
Johannes Truschnigg 2016-12-02 18:30:40 +01:00 committed by Brian Coca
parent 819c51cd80
commit b377301195

View file

@ -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'] = ""