]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk-prepare: Allow setting mkfs arguments and mount options in ceph.conf
authorTommi Virtanen <tv@inktank.com>
Tue, 2 Oct 2012 23:23:55 +0000 (16:23 -0700)
committerTommi Virtanen <tv@inktank.com>
Fri, 5 Oct 2012 22:41:34 +0000 (15:41 -0700)
Tested with meaningless but easy-to-verify values:

  [global]
  osd_fs_type = xfs
  osd_fs_mkfs_arguments_xfs = -i size=512
  osd_fs_mount_options_xfs = noikeep

ceph-disk-activate does not respect the mount options yet.

Closes: #2549
Signed-off-by: Tommi Virtanen <tv@inktank.com>
src/ceph-disk-prepare

index 2edaf464bdec792694c513aee3495b514e5ccf46..59022078592fe2eceb2ce6a5438a264426d7c51c 100755 (executable)
@@ -115,9 +115,11 @@ MKFS_ARGS = dict(
 def mount(
     dev,
     fstype,
+    options,
     ):
     # pick best-of-breed mount options based on fs type
-    options = MOUNT_OPTIONS.get(fstype, '')
+    if options is None:
+        options = MOUNT_OPTIONS.get(fstype, '')
 
     # mount
     path = tempfile.mkdtemp(
@@ -164,6 +166,8 @@ def unmount(
 def prepare(
     disk,
     fstype,
+    mkfs_args,
+    mount_options,
     cluster_uuid,
     ):
     """
@@ -198,6 +202,9 @@ def prepare(
         '--type={fstype}'.format(fstype=fstype),
         ]
     args.extend(MKFS_ARGS.get(fstype, []))
+    if mkfs_args is not None:
+        args.extend(mkfs_args.split())
+    args.extend
     args.extend([
             '--',
             dev,
@@ -207,7 +214,7 @@ def prepare(
     except subprocess.CalledProcessError as e:
         raise PrepareError(e)
 
-    path = mount(dev=dev, fstype=fstype)
+    path = mount(dev=dev, fstype=fstype, options=mount_options)
     try:
         write_one_line(path, 'ceph_fsid', cluster_uuid)
         osd_uuid = str(uuid.uuid4())
@@ -280,9 +287,26 @@ def main():
                 )
             if args.fs_type is None:
                 args.fs_type = DEFAULT_FS_TYPE
+
+        mkfs_args = get_conf(
+            cluster=args.cluster,
+            variable='osd_fs_mkfs_arguments_{fstype}'.format(
+                fstype=args.fs_type,
+                ),
+            )
+
+        mount_options = get_conf(
+            cluster=args.cluster,
+            variable='osd_fs_mount_options_{fstype}'.format(
+                fstype=args.fs_type,
+                ),
+            )
+
         prepare(
             disk=args.disk,
             fstype=args.fs_type,
+            mkfs_args=mkfs_args,
+            mount_options=mount_options,
             cluster_uuid=args.cluster_uuid,
             )
     except PrepareError as e: