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

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