From: Sage Weil Date: Wed, 13 Aug 2014 00:25:42 +0000 (-0700) Subject: ceph-disk: move fs mount probe into a helper X-Git-Tag: v0.80.6~59 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b09e659226b26002b58c7697f8c600d06fe78c58;p=ceph.git ceph-disk: move fs mount probe into a helper Signed-off-by: Sage Weil (cherry picked from commit f80ed26d2403ba12e80da6459fc45c22584f72de) --- diff --git a/src/ceph-disk b/src/ceph-disk index 79bfcc330c04..9ff7f5c81083 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -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: