summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-03-05 13:08:26 -0800
committerSage Weil <sage@inktank.com>2013-03-05 13:08:26 -0800
commit32407c994f309cd788bf13fe9af27e17a422309a (patch)
tree2f6ef99a41c729df6e3175b6153e16d3727cc11d
parenta6196de9e2f3ca9d67691f79d44e9a9f669443e9 (diff)
downloadceph-32407c994f309cd788bf13fe9af27e17a422309a.tar.gz
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 <sage@inktank.com>
-rwxr-xr-xsrc/ceph-disk-prepare24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/ceph-disk-prepare b/src/ceph-disk-prepare
index 2811a1f7073..d8ee86f1243 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)