From 2591f6371e6ccaa247aff43c56b49a553471a1b7 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 24 Jan 2016 17:07:58 +0700 Subject: [PATCH] ceph-disk: use the type file for bluestore The type file in the OSD bluestore data exists and contains the bluestore string. ceph-disk activate should use it instead of the "osd objectstore" configuration value. It is better in case the configuration file changes between prepare and activate. The fsid file cannot be used by bluestore to signify that ceph-osd --mkfs has completed successfully because it is pre-populated by ceph-disk. Introduce the mkfs_done file, dedicated to this, instead of overloading an existing file. Signed-off-by: Sage Weil Signed-off-by: Loic Dachary --- src/ceph-disk/ceph_disk/main.py | 8 +++--- src/os/bluestore/BlueStore.cc | 45 +++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/ceph-disk/ceph_disk/main.py b/src/ceph-disk/ceph_disk/main.py index e9556567074a..aaf31ac5e8a2 100755 --- a/src/ceph-disk/ceph_disk/main.py +++ b/src/ceph-disk/ceph_disk/main.py @@ -2412,11 +2412,9 @@ def mkfs( ], ) - osd_objectstore = get_conf( - cluster=cluster, - variable='osd_objectstore', - ) - if osd_objectstore == 'bluestore': + osd_type = read_one_line(path, 'type') + + if osd_type == 'bluestore': command_check_call( [ 'ceph-osd', diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 268ed5529801..9c5bc52be9ef 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1641,6 +1641,29 @@ int BlueStore::mkfs() int r; uuid_d old_fsid; + { + string done; + r = read_meta("mkfs_done", &done); + if (r == 0) { + dout(1) << __func__ << " already created" << dendl; + return 0; // idempotent + } + } + + { + string type; + r = read_meta("type", &type); + if (r == 0) { + if (type != "bluestore") { + dout(1) << __func__ << " expected bluestore, but type is " << type << dendl; + return -EIO; + } + } + r = write_meta("type", "bluestore"); + if (r < 0) + return r; + } + r = _open_path(); if (r < 0) return r; @@ -1670,8 +1693,6 @@ int BlueStore::mkfs() goto out_close_fsid; } fsid = old_fsid; - dout(1) << __func__ << " already created, fsid is " << fsid << dendl; - goto out_close_fsid; } r = _setup_block_symlink_or_file("block", g_conf->bluestore_block_path, @@ -1748,16 +1769,20 @@ int BlueStore::mkfs() r = write_meta("bluefs", stringify((int)g_conf->bluestore_bluefs)); if (r < 0) goto out_close_alloc; - r = write_meta("type", "bluestore"); + + if (fsid != old_fsid) { + r = _write_fsid(); + if (r < 0) { + derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl; + goto out_close_alloc; + } + } + + // indicate success by writing the 'mkfs_done' file + r = write_meta("mkfs_done", "yes"); if (r < 0) goto out_close_alloc; - - // indicate mkfs completion/success by writing the fsid file - r = _write_fsid(); - if (r == 0) - dout(10) << __func__ << " success" << dendl; - else - derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl; + dout(10) << __func__ << " success" << dendl; out_close_alloc: _close_alloc(); -- 2.47.3