From: islepnev Date: Fri, 17 Apr 2015 19:33:01 +0000 (+0300) Subject: ceph-disk: support NVMe device partitions X-Git-Tag: v0.80.11~78^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=90a1a7587fcb567e2cc6e9188fdd56ec1255a881;p=ceph.git ceph-disk: support NVMe device partitions Linux nvme kernel module v0.9 enumerate devices as following: /dev/nvme0 - characted revice /dev/nvme0n1 - whole block device /dev/nvme0n1p1 - first partition /dev/nvme0n1p2 - second partition http://tracker.ceph.com/issues/11612 Fixes: #11612 Signed-off-by: Ilja Slepnev (cherry picked from commit 9b62cf254d02d30609793be8b1cb8a94f38891f1) Conflicts: src/ceph-disk --- diff --git a/src/ceph-disk b/src/ceph-disk index 6bd02201bd8..4627a43ec7a 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -2158,6 +2158,13 @@ def get_dev_fs(dev): return None +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) + else: + return re.match('(\D+)(\d+)', dev).group(1, 2) + + def get_partition_type(part): """ Get the GPT partition type UUID. If we have an old blkid and can't @@ -2207,7 +2214,7 @@ def get_partition_type(part): if 'blkid' not in warned_about: LOG.warning('Old blkid does not support ID_PART_ENTRY_* fields, trying sgdisk; may not correctly identify ceph volumes with dmcrypt') warned_about['blkid'] = True - (base, partnum) = re.match('(\D+)(\d+)', part).group(1, 2) + (base, partnum) = split_dev_base_partnum(part) sgdisk, _ = command( [ 'sgdisk', @@ -2233,7 +2240,7 @@ def get_partition_type(part): def get_partition_uuid(dev): - (base, partnum) = re.match('(\D+)(\d+)', dev).group(1, 2) + (base, partnum) = split_dev_base_partnum(dev) out, _ = command(['sgdisk', '-i', partnum, base]) for line in out.splitlines(): m = re.match('Partition unique GUID: (\S+)', line)