From a146f053e5e0176be84292bd2623c3eb9fa276ea Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 2 Oct 2012 16:23:55 -0700 Subject: [PATCH] ceph-disk-prepare: Allow setting mkfs arguments and mount options in ceph.conf 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 --- src/ceph-disk-prepare | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/ceph-disk-prepare b/src/ceph-disk-prepare index 2edaf464bdec7..59022078592fe 100755 --- a/src/ceph-disk-prepare +++ b/src/ceph-disk-prepare @@ -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: -- 2.39.5