From 560ee483a9ff0fbaa130e70573c7f27ba7a413ad Mon Sep 17 00:00:00 2001 From: Maurizio Lombardi Date: Fri, 19 Oct 2018 10:52:01 +0200 Subject: [PATCH] report the correct size for partitions If you use a partition instead of the whole device as the backstore device, rtslib will always report its size as 0 bytes. This happens because rtslib tries to read the "queue/logical_block_size" attribute, which can only be found in the parent's node. This patch fixes the bug by loading the parent node's attributes if it detects that the device is a partition. Signed-off-by: Maurizio Lombardi --- rtslib/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rtslib/utils.py b/rtslib/utils.py index b4e68fb..eff2205 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -134,6 +134,9 @@ def _get_size_for_dev(device): except (KeyError, UnicodeDecodeError, ValueError): return 0 + if device['DEVTYPE'] == 'partition': + attributes = device.parent.attributes + try: logical_block_size = attributes.asint('queue/logical_block_size') except (KeyError, UnicodeDecodeError, ValueError): -- 1.8.3.1