],
)
- 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',
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;
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,
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();