]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk-prepare: move in-use checks to the top, before zap
authorSage Weil <sage@inktank.com>
Tue, 5 Mar 2013 21:08:26 +0000 (13:08 -0800)
committerSage Weil <sage@inktank.com>
Fri, 26 Apr 2013 20:40:03 +0000 (13:40 -0700)
Move the in-use checks to the very top, before we (say) zap!

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 32407c994f309cd788bf13fe9af27e17a422309a)

src/ceph-disk-prepare

index 2811a1f707364dff286b5a7181b9d56144e85482..d8ee86f1243b7334ce2c8e8045a0e96ecc206d27 100755 (executable)
@@ -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)