def _sizes(dev):
    dev = _devbase(dev)

    # standarization yay
    block_sizes = ('hw_sector_size', 'minimum_io_size', 'physical_block_size', 'logical_block_size')
    discard_sizes = ('discard_max_bytes', 'discard_max_hw_bytes', )

    sysfs = __salt__['sysfs.read'](
        ('size',
         'queue/hw_sector_size', '../queue/hw_sector_size',
         'queue/discard_max_bytes', '../queue/discard_max_bytes'),
        root=_syspath(dev))

    # TODO: makes no sense
    # First of all, it has to be a power of 2
    # Secondly, this returns 4GiB - 512b on Intel 3500's for some weird reason
    # discard_granularity seems in bytes, resolves to 512b ???
    # max_hw_sectors_kb???
    # There's also discard_max_hw_bytes more recently
    # See: https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
    # Also, I cant find any docs yet regarding bucket sizes;
    # it's supposed to be discard_max_hw_bytes,
    # but no way to figure that one reliably out apparently

    discard = sysfs.get('queue/discard_max_bytes', sysfs.get('../queue/discard_max_bytes', None))
    block = sysfs.get('queue/hw_sector_size', sysfs.get('../queue/hw_sector_size', None))

    return 512*sysfs['size'], block, discard
Return neigh useless sizing info about a blockdev
dataset/ETHPy150Open saltstack/salt/salt/modules/bcache.py/_sizes