From: Sage Weil Date: Tue, 5 Mar 2013 21:08:26 +0000 (-0800) Subject: ceph-disk-prepare: move in-use checks to the top, before zap X-Git-Tag: v0.56.5~5^2~52 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=35eac085182e569b17c287c86e1415880909be22;p=ceph.git ceph-disk-prepare: move in-use checks to the top, before zap Move the in-use checks to the very top, before we (say) zap! Signed-off-by: Sage Weil (cherry picked from commit 32407c994f309cd788bf13fe9af27e17a422309a) --- diff --git a/src/ceph-disk-prepare b/src/ceph-disk-prepare index 2811a1f70736..d8ee86f1243b 100755 --- a/src/ceph-disk-prepare +++ b/src/ceph-disk-prepare @@ -436,9 +436,6 @@ def prepare_journal_dev( journal_dm_keypath, ): - if os.path.exists(journal): - verify_not_in_use(journal) - if is_partition(journal): log.debug('Journal %s is a partition', journal) log.warning('OSD will not be hot-swappable if journal is not the same device as the osd data') @@ -862,12 +859,18 @@ def main(): if not os.path.exists(args.data): raise PrepareError('data path does not exist', args.data) - # FIXME: verify disk/partitions is not in use + # in use? + dmode = os.stat(args.data).st_mode + if stat.S_ISBLK(dmode): + verify_not_in_use(args.data) + + if args.journal and os.path.exists(args.journal): + jmode = os.stat(args.journal).st_mode + if stat.S_ISBLK(jmode): + verify_not_in_use(args.journal) + if args.zap_disk is not None: - if not os.path.exists(args.data): - raise PrepareError('does not exist', args.data) - mode = os.stat(args.data).st_mode - if stat.S_ISBLK(mode) and not is_partition(args.data): + if stat.S_ISBLK(dmode) and not is_partition(args.data): zap(args.data) else: raise PrepareError('not full block device; cannot zap', args.data) @@ -926,11 +929,6 @@ def main(): ) journal_size = int(journal_size) - # in use? - dmode = os.stat(args.data).st_mode - if stat.S_ISBLK(dmode): - verify_not_in_use(args.data) - # colocate journal with data? if stat.S_ISBLK(dmode) and not is_partition(args.data) and args.journal is None and args.journal_file is None: log.info('Will colocate journal with data on %s', args.data)