]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: multipath support for split_dev_base_partnum
authorLoic Dachary <ldachary@redhat.com>
Mon, 17 Aug 2015 21:51:24 +0000 (23:51 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sat, 29 Aug 2015 00:37:51 +0000 (02:37 +0200)
split_dev_base_partnum returns the path of the whole disk in
/dev/mapper. The base variable name to designate the device for the
whole disk is a misnomer since it cannot be used as a basename to
rebuild the parition device name in the case of multipath.

The logic of split_dev_base_partnum for devices is reworked to use
/sys/dev/block/M:m/partition instead of device name parsing.

http://tracker.ceph.com/issues/11881 Refs: #11881

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/ceph-disk

index 38755ac5ac21005fc886c91a95f4af670c678d32..26c19f2e11b03ecc2fb1717de0a4462b8197b067 100755 (executable)
@@ -574,6 +574,18 @@ def is_partition_mpath(dev):
     uuid = get_dm_uuid(dev)
     return bool(re.match('part\d+-mpath-', uuid))
 
+def partnum_mpath(dev):
+    uuid = get_dm_uuid(dev)
+    return re.findall('part(\d+)-mpath-', uuid)[0]
+
+def get_partition_base_mpath(dev):
+    slave_path = os.path.join(block_path(dev), 'slaves')
+    slaves = os.listdir(slave_path)
+    assert slaves
+    name_path = os.path.join(slave_path, slaves[0], 'dm', 'name')
+    name = open(name_path, 'r').read().strip()
+    return os.path.join('/dev/mapper', name)
+
 def is_partition(dev):
     """
     Check whether a given device path is a partition or a full disk.
@@ -2565,11 +2577,14 @@ def get_dev_fs(dev):
 
 
 def split_dev_base_partnum(dev):
-    if 'loop' in dev or 'cciss' in dev or 'nvme' in dev:
-        return re.match('(.*\d+)p(\d+)', dev).group(1, 2)
+    if is_mpath(dev):
+        partnum = partnum_mpath(dev)
+        base = get_partition_base_mpath(dev)
     else:
-        return re.match('(\D+)(\d+)', dev).group(1, 2)
-
+        b = block_path(dev)
+        partnum = open(os.path.join(b, 'partition')).read().strip()
+        base = get_partition_base(dev)
+    return (base, partnum)
 
 def get_partition_type(part):
     """