From: Loic Dachary Date: Sun, 20 Sep 2015 12:30:52 +0000 (+0200) Subject: ceph-disk: guard partprobe with udevadm settle X-Git-Tag: v9.1.0~89^2^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2c553ee95008cce1da7d6c695f6fb30b2584386;p=ceph.git ceph-disk: guard partprobe with udevadm settle Call udevadm settle before and after partprobe. A side effect of partprobe is to remove partitions and add them again. The first udevadm settle waits for ongoing udev events to complete, just in case one of them rely on an existing partition on dev. The second udevadm settle guarantees to the caller that all udev events related to the partition table change have been processed, i.e. the 95-ceph-osd.rules actions and mode changes, group changes etc. are complete. Signed-off-by: Loic Dachary --- diff --git a/src/ceph-disk b/src/ceph-disk index e219d8a56679..27040d18ec33 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -1207,14 +1207,21 @@ def get_free_partition_index(dev): def update_partition(dev, description): - LOG.debug('Calling partprobe on %s device %s', description, dev) - command( - [ - 'partprobe', - dev, - ], - ) - + """ + Must be called after modifying a partition table so the kernel + know about the change and fire udev events accordingly. A side + effect of partprobe is to remove partitions and add them again. + The first udevadm settle waits for ongoing udev events to + complete, just in case one of them rely on an existing partition + on dev. The second udevadm settle guarantees to the caller that + all udev events related to the partition table change have been + processed, i.e. the 95-ceph-osd.rules actions and mode changes, + group changes etc. are complete. + """ + LOG.debug('Calling partprobe on %s device %s', description, dev) + command_check_call(['udevadm', 'settle']) + command_check_call(['partprobe', dev]) + command_check_call(['udevadm', 'settle']) def zap(dev): """ @@ -1374,14 +1381,6 @@ def prepare_journal_dev( update_partition(journal, 'prepared') - # wait for udev event queue to clear - command( - [ - 'udevadm', - 'settle', - ], - ) - LOG.debug('Journal is GPT partition %s', journal_symlink) if journal_dm_keypath: @@ -1593,13 +1592,6 @@ def prepare_dev( ], ) update_partition(data, 'created') - command( - [ - # wait for udev event queue to clear - 'udevadm', - 'settle', - ], - ) except subprocess.CalledProcessError as e: raise Error(e)