]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: use blkid instead of sgdisk -i 7475/head
authorLoic Dachary <ldachary@redhat.com>
Fri, 18 Dec 2015 16:03:21 +0000 (17:03 +0100)
committerLoic Dachary <ldachary@redhat.com>
Tue, 2 Feb 2016 06:18:04 +0000 (13:18 +0700)
sgdisk -i 1 /dev/vdb opens /dev/vdb in write mode which indirectly
triggers a BLKRRPART ioctl from udev (starting version 214 and up) when
the device is closed (see below for the udev release note). The
implementation of this ioctl by the kernel (even old kernels) removes
all partitions and adds them again (similar to what partprobe does
explicitly).

The side effects of partitions disappearing while ceph-disk is running
are devastating.

sgdisk is replaced by blkid which only opens the device in read mode and
will not trigger this unexpected behavior.

The problem does not show on Ubuntu 14.04 because it is running udev <
214 but shows on CentOS 7 which is running udev > 214.

git clone git://anonscm.debian.org/pkg-systemd/systemd.git
systemd/NEWS:
CHANGES WITH 214:

        * As an experimental feature, udev now tries to lock the
          disk device node (flock(LOCK_SH|LOCK_NB)) while it
          executes events for the disk or any of its partitions.
          Applications like partitioning programs can lock the
          disk device node (flock(LOCK_EX)) and claim temporary
          device ownership that way; udev will entirely skip all event
          handling for this disk and its partitions. If the disk
          was opened for writing, the close will trigger a partition
          table rescan in udev's "watch" facility, and if needed
          synthesize "change" events for the disk and all its partitions.
          This is now unconditionally enabled, and if it turns out to
          cause major problems, we might turn it on only for specific
          devices, or might need to disable it entirely. Device Mapper
          devices are excluded from this logic.

http://tracker.ceph.com/issues/14094 Fixes: #14094

Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 9dce05a8cdfc564c5162885bbb67a04ad7b95c5a)

Conflicts:
src/ceph-disk: keep get_partition_type as it is because
        some hammer users may rely on the fact that it is able
        to fallback to sgdisk if blkid is old. Chances are an
        old blkid also means an old udev that does not have the
        problem this fix is adressing. The get_partition_uuid
        is modified to try blkid first, with the same rationale.

src/ceph-disk

index a32200cd3076bc84ede40d95f1a0803a2ae1b122..6b64fd4e8b417e6cde17385febc587b2698c42e9 100755 (executable)
@@ -2440,6 +2440,28 @@ def get_partition_type(part):
 
 
 def get_partition_uuid(dev):
+    #
+    # blkid is prefered
+    #
+    what = 'ID_PART_ENTRY_UUID'
+    out, _ = command(
+        [
+            'blkid',
+            '-o',
+            'udev',
+            '-p',
+            dev,
+        ]
+    )
+    p = {}
+    for line in out.splitlines():
+        (key, value) = line.split('=')
+        p[key] = value
+    if what in p:
+        return p[what]
+    #
+    # if blkid does not deliver, fallback to sgdisk
+    #
     (base, partnum) = split_dev_base_partnum(dev)
     out, _ = command(['sgdisk', '-i', partnum, base])
     for line in out.splitlines():