mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
ceph-disk: multipath support for split_dev_base_partnum
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>
This commit is contained in:
parent
3bc95dfc1b
commit
77ff7c3dc6
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user