Blame SOURCES/0003-report-the-correct-size-for-partitions.patch

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