return (fm && fm->is_null_manager());
}
+int BlueStore::mount_readonly()
+{
+ int r = _mount_readonly();
+ if (r < 0) {
+ return r;
+ }
+ r = _open_collections();
+ if (r < 0) {
+ return r;
+ }
+ auto shutdown_cache = make_scope_guard([&] {
+ if (!mounted) {
+ _shutdown_cache();
+ }
+ });
+
+ _kv_start();
+ auto stop_kv = make_scope_guard([&] {
+ if (!mounted) {
+ _kv_stop();
+ }
+ });
+
+ r = _deferred_replay();
+ if (r < 0) {
+ return r;
+ }
+ mempool_thread.init();
+ mounted = true;
+ return r;
+}
+
+int BlueStore::_mount_readonly()
+{
+ dout(5) << __func__ << dendl;
+ {
+ string type;
+ int r = read_meta("type", &type);
+ if (r < 0) {
+ derr << __func__ << " failed to load os-type: " << cpp_strerror(r)
+ << dendl;
+ return r;
+ }
+
+ if (type != "bluestore") {
+ derr << __func__ << " expected bluestore, but type is " << type << dendl;
+ return -EIO;
+ }
+ }
+
+ int r = _open_path();
+ if (r < 0)
+ return r;
+ r = _open_fsid(false);
+ if (r < 0)
+ goto out_path;
+
+ r = _read_fsid(&fsid);
+ if (r < 0)
+ goto out_fsid;
+
+ r = _lock_fsid();
+ if (r < 0)
+ goto out_fsid;
+
+ r = _open_bdev(false);
+ if (r < 0)
+ goto out_fsid;
+
+ r = _open_db(false, false, true);
+ if (r < 0)
+ goto out_bdev;
+
+ r = _open_super_meta();
+ if (r < 0) {
+ goto out_db;
+ }
+ return 0;
+
+out_db:
+ _close_db();
+out_bdev:
+ _close_bdev();
+ out_fsid:
+ _close_fsid();
+out_path:
+ _close_path();
+ return r;
+}
+
+int BlueStore::umount_readonly()
+{
+ ceph_assert(_kv_only || mounted);
+ _osr_drain_all();
+
+ mounted = false;
+
+ if (!_kv_only) {
+ mempool_thread.shutdown();
+ dout(20) << __func__ << " stopping kv thread" << dendl;
+ _kv_stop();
+ // skip cache cleanup step on fast shutdown
+ if (likely(!m_fast_shutdown)) {
+ _shutdown_cache();
+ }
+ dout(20) << __func__ << " closing" << dendl;
+ }
+ return _umount_readonly();
+}
+
+int BlueStore::_umount_readonly()
+{
+ dout(5) << __func__ << dendl;
+ if (db) {
+ _close_db();
+ }
+ if (bluefs) {
+ _close_bluefs();
+ }
+ _close_bdev();
+ _close_fsid();
+ _close_path();
+ return 0;
+}
+
int BlueStore::_mount()
{
dout(5) << __func__ << " path " << path << dendl;
bool discard_queued = false;
// it's expected we're called with lazy_release_lock already taken!
if (unlikely(cct->_conf->bluestore_debug_no_reuse_blocks ||
- txc->released.size() == 0)) {
+ txc->released.size() == 0 ||
+ !alloc)) {
goto out;
}
discard_queued = bdev->try_discard(txc->released);
auto sync_start = mono_clock::now();
#endif
// submit synct synchronously (block and wait for it to commit)
- int r = cct->_conf->bluestore_debug_omit_kv_commit ? 0 : db->submit_transaction_sync(synct);
+ int r = db_was_opened_read_only || cct->_conf->bluestore_debug_omit_kv_commit ?
+ 0 : db->submit_transaction_sync(synct);
ceph_assert(r == 0);
#ifdef WITH_BLKIN
return 0;
}
- int ret = fs->mount();
+ int ret;
+ bool mount_readonly =
+ op == "export" ||
+ op == "list" ||
+ op == "list-pgs" ||
+ op == "meta-list" ||
+ op == "get-osdmap" ||
+ op == "get-superblock" ||
+ op == "get-inc-osdmap" ||
+ objcmd == "get-bytes" ||
+ objcmd == "get-attrs" ||
+ objcmd == "get-omap" ||
+ objcmd == "get-omaphdr" ||
+ objcmd == "list-attrs" ||
+ objcmd == "list-omap" ||
+ objcmd == "dump";
+ if(mount_readonly) {
+ ret = fs->mount_readonly();
+ } else {
+ ret = fs->mount();
+ }
+
if (ret < 0) {
if (ret == -EBUSY) {
cerr << "OSD has the store locked" << std::endl;
cout << ostr.str() << std::endl;
}
- int r = fs->umount();
+ int r = mount_readonly ? fs->umount_readonly() : fs->umount();
if (r < 0) {
cerr << "umount failed: " << cpp_strerror(r) << std::endl;
// If no previous error, then use umount() error