]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.prepare allow and dedupe extra flags for mounting
authorAlfredo Deza <adeza@redhat.com>
Mon, 16 Apr 2018 16:44:24 +0000 (12:44 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 18 Apr 2018 18:48:47 +0000 (14:48 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 81c20e6b58b77671ffaa0f8030f18747e1a23569)

src/ceph-volume/ceph_volume/util/prepare.py

index 8c16c19d243d8114887c234931e99d2e06707716..b8e9d3183647f957438d046076d84c9e596610d7 100644 (file)
@@ -166,20 +166,27 @@ def _normalize_mount_flags(flags, extras=None):
         if extras:
             flags.extend(extras)
         # ensure that spaces and commas are removed so that they can join
-        # correctly
-        return ','.join([f.strip().strip(',') for f in flags if f])
+        # correctly, remove duplicates
+        flags = set([f.strip().strip(',') for f in flags if f])
+        return ','.join(flags)
 
     # split them, clean them, and join them back again
     flags = flags.strip().split(' ')
     if extras:
         flags.extend(extras)
-    return ','.join(
-        [f.strip().strip(',') for f in flags if f]
-    )
+
+    # remove possible duplicates
+    flags = ','.join([f.strip().strip(',') for f in flags if f])
+    # Before returning, split them again, since strings can be mashed up
+    # together, preventing removal of duplicate entries
+    return ','.join(set(flags.split(',')))
 
 
 def mount_osd(device, osd_id, **kw):
-    is_vdo = kw.get('is_vdo', 0)
+    extras = []
+    is_vdo = kw.get('is_vdo', '0')
+    if is_vdo == '1':
+        extras = ['discard']
     destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id)
     command = ['mount', '-t', 'xfs', '-o']
     flags = conf.ceph.get_list(
@@ -188,7 +195,9 @@ def mount_osd(device, osd_id, **kw):
         default=constants.mount.get('xfs'),
         split=' ',
     )
-    command.append(_normalize_mount_flags(flags))
+    command.append(
+        _normalize_mount_flags(flags, extras=extras)
+    )
     command.append(device)
     command.append(destination)
     process.run(command)