From 8b3b59e01432090f7ae774e971862316203ade68 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 11 Jun 2013 18:35:01 -0700 Subject: [PATCH] ceph-disk: call partprobe outside of the prepare lock; drop udevadm settle After we change the final partition type, sgdisk may or may not trigger a udev event, depending on how well udev is behaving (it varies between distros, it seems). The old code would often settle and wait for udev to activate the device, and then partprobe would uselessly fail because it was already mounted. Call partprobe only at the very end, after prepare is done. This ensures that if partprobe calls udevadm settle (which is sometimes does) we do not get stuck. Drop the udevadm settle. I'm not sure what this accomplishes; take it out, at least until we determine we need it. Signed-off-by: Sage Weil --- src/ceph-disk | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 6ee15da736b9f..d5642c58a9248 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -761,14 +761,6 @@ def prepare_journal_dev( # wait for udev event queue to clear 'udevadm', 'settle', - '--timeout=10', - ], - ) - subprocess.check_call( - args=[ - # also make sure the kernel refreshes the new table - 'partprobe', - journal, ], ) @@ -963,14 +955,6 @@ def prepare_dev( # wait for udev event queue to clear 'udevadm', 'settle', - '--timeout=10', - ], - ) - subprocess.check_call( - args=[ - # also make sure the kernel refreshes the new table - 'partprobe', - data, ], ) except subprocess.CalledProcessError as e: @@ -1037,21 +1021,6 @@ def prepare_dev( data, ], ) - subprocess.call( - args=[ - # wait for udev event queue to clear - 'udevadm', - 'settle', - '--timeout=10', - ], - ) - subprocess.check_call( - args=[ - # also make sure the kernel refreshes the new table - 'partprobe', - data, - ], - ) except subprocess.CalledProcessError as e: raise Error(e) @@ -1192,6 +1161,19 @@ def main_prepare(args): raise Error('not a dir or block device', args.data) prepare_lock.release() + if stat.S_ISBLK(dmode): + # try to make sure the kernel refreshes the table. note + # that if this gets ebusy, we are probably racing with + # udev because it already updated it.. ignore failure here. + LOG.debug('Calling partprobe on prepared device %s', args.data) + subprocess.call( + args=[ + 'partprobe', + args.data, + ], + ) + + except Error as e: if journal_dm_keypath: os.unlink(journal_dm_keypath) -- 2.39.5