]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: move fs mount probe into a helper
authorSage Weil <sage@redhat.com>
Wed, 13 Aug 2014 00:25:42 +0000 (17:25 -0700)
committerSage Weil <sage@redhat.com>
Sat, 16 Aug 2014 00:15:37 +0000 (17:15 -0700)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit f80ed26d2403ba12e80da6459fc45c22584f72de)

src/ceph-disk

index 79bfcc330c04670f0e27581cd8d5dd68737691c1..9ff7f5c81083a0c4e97ba4d1338256af65b1083a 100755 (executable)
@@ -2207,6 +2207,27 @@ def more_osd_info(path, uuid_map):
 
     return desc
 
+def list_dev_osd(dev, uuid_map):
+    path = is_mounted(dev)
+    fs_type = get_dev_fs(dev)
+    desc = []
+    if path:
+        desc.append('active')
+        desc.extend(more_osd_info(path, uuid_map))
+    elif fs_type:
+        try:
+            tpath = mount(dev=dev, fstype=fs_type, options='')
+            if tpath:
+                try:
+                    magic = get_oneliner(tpath, 'magic')
+                    if magic is not None:
+                        desc.append('prepared')
+                        desc.extend(more_osd_info(tpath, uuid_map))
+                finally:
+                    unmount(tpath)
+        except MountError:
+            pass
+    return desc
 
 def list_dev(dev, uuid_map, journal_map):
     ptype = 'unknown'
@@ -2214,27 +2235,10 @@ def list_dev(dev, uuid_map, journal_map):
     if is_partition(dev):
         ptype = get_partition_type(dev)
         prefix = ' '
-    fs_type = get_dev_fs(dev)
-    path = is_mounted(dev)
 
     desc = []
     if ptype == OSD_UUID:
-        if path:
-            desc.append('active')
-            desc.extend(more_osd_info(path, uuid_map))
-        elif fs_type:
-            try:
-                tpath = mount(dev=dev, fstype=fs_type, options='')
-                if tpath:
-                    try:
-                        magic = get_oneliner(tpath, 'magic')
-                        if magic is not None:
-                            desc.append('prepared')
-                            desc.extend(more_osd_info(tpath, uuid_map))
-                    finally:
-                        unmount(tpath)
-            except MountError:
-                pass
+        desc = list_dev_osd(dev, uuid_map)
         if desc:
             desc = ['ceph data'] + desc
         else:
@@ -2245,6 +2249,8 @@ def list_dev(dev, uuid_map, journal_map):
         if part_uuid and part_uuid in journal_map:
             desc.append('for %s' % journal_map[part_uuid])
     else:
+        path = is_mounted(dev)
+        fs_type = get_dev_fs(dev)
         if is_swap(dev):
             desc.append('swap')
         else: