return r;
}
-void BlueFS::umount()
+void BlueFS::umount(bool avoid_compact)
{
dout(1) << __func__ << dendl;
- sync_metadata();
+ sync_metadata(avoid_compact);
_close_writer(log_writer);
log_writer = NULL;
return 0;
}
-void BlueFS::sync_metadata()
+void BlueFS::sync_metadata(bool avoid_compact)
{
std::unique_lock l(lock);
if (log_t.empty()) {
dout(10) << __func__ << " done in " << (ceph_clock_now() - start) << dendl;
}
- if (_should_compact_log()) {
+ if (!avoid_compact && _should_compact_log()) {
if (cct->_conf->bluefs_compact_log_sync) {
_compact_log_sync();
} else {
// the super is always stored on bdev 0
int mkfs(uuid_d osd_uuid);
int mount();
- void umount();
+ void umount(bool avoid_compact = false);
int prepare_new_device(int id);
int log_dump();
void compact_log();
/// sync any uncommitted state to disk
- void sync_metadata();
+ void sync_metadata(bool avoid_compact);
void set_slow_device_expander(BlueFSDeviceExpander* a) {
slow_dev_expander = a;
// Fsync directory. Can be called concurrently from multiple threads.
rocksdb::Status Fsync() override {
// it is sufficient to flush the log.
- fs->sync_metadata();
+ fs->sync_metadata(false);
return rocksdb::Status::OK();
}
};
return r;
}
-void BlueStore::_close_bluefs()
+void BlueStore::_close_bluefs(bool cold_close)
{
- bluefs->umount();
+ bluefs->umount(cold_close);
_minimal_close_bluefs();
}
// now open in R/W mode
if (!read_only) {
- _close_db();
+ _close_db(true);
r = _open_db(false, false, false);
if (r < 0) {
out_fm:
_close_fm();
out_db:
- _close_db();
+ _close_db(read_only);
return r;
}
-void BlueStore::_close_db_and_around()
+void BlueStore::_close_db_and_around(bool read_only)
{
if (bluefs) {
- if (out_of_sync_fm.fetch_and(0)) {
+ if (!read_only && out_of_sync_fm.fetch_and(0)) {
_sync_bluefs_and_fm();
}
- _close_db();
- while(out_of_sync_fm.fetch_and(0)) {
+ _close_db(read_only);
+ while(!read_only && out_of_sync_fm.fetch_and(0)) {
// if seen some allocations during close - repeat open_db, sync fm, close
dout(0) << __func__ << " syncing FreelistManager" << dendl;
int r = _open_db(false, false, false);
break;
}
_sync_bluefs_and_fm();
- _close_db();
+ _close_db(false);
}
if (!_kv_only) {
_close_alloc();
} else {
_close_alloc();
_close_fm();
- _close_db();
+ _close_db(read_only);
}
}
if (!db) {
derr << __func__ << " error creating db" << dendl;
if (bluefs) {
- _close_bluefs();
+ _close_bluefs(read_only);
}
// delete env manually here since we can't depend on db to do this
// under this case
}
if (r) {
derr << __func__ << " erroring opening db: " << err.str() << dendl;
- _close_db();
+ _close_db(read_only);
return -EIO;
}
dout(1) << __func__ << " opened " << kv_backend
return 0;
}
-void BlueStore::_close_db()
+void BlueStore::_close_db(bool cold_close)
{
ceph_assert(db);
delete db;
db = NULL;
if (bluefs) {
- _close_bluefs();
+ _close_bluefs(cold_close);
}
}
out_close_fm:
_close_fm();
out_close_db:
- _close_db();
+ _close_db(false);
out_close_bdev:
_close_bdev();
out_close_fsid:
void BlueStore::_umount_for_bluefs()
{
- _close_bluefs();
+ _close_bluefs(false);
_close_fsid();
_close_path();
}
out_coll:
_flush_cache();
out_db:
- _close_db_and_around();
+ _close_db_and_around(false);
out_bdev:
_close_bdev();
out_fsid:
dout(20) << __func__ << " closing" << dendl;
}
- _close_db_and_around();
+ _close_db_and_around(false);
_close_bdev();
_close_fsid();
_close_path();
}
int BlueStore::cold_close()
{
- _close_db_and_around();
+ _close_db_and_around(true);
_close_bdev();
_close_fsid();
_close_path();
mempool_thread.shutdown();
_flush_cache();
out_db:
- _close_db_and_around();
+ _close_db_and_around(false);
out_bdev:
_close_bdev();
out_fsid:
[&](uint64_t pos, mempool_dynamic_bitset &bs) {
ceph_assert(pos < bs.size());
bs.set(pos);
- }
- );
+ });
}
int r = bluefs->fsck();
if (r < 0) {
int _minimal_open_bluefs(bool create);
void _minimal_close_bluefs();
int _open_bluefs(bool create);
- void _close_bluefs();
+ void _close_bluefs(bool cold_close);
// Limited (u)mount intended for BlueFS operations only
int _mount_for_bluefs();
* in the proper order
*/
int _open_db_and_around(bool read_only);
- void _close_db_and_around();
+ void _close_db_and_around(bool read_only);
// updates legacy bluefs related recs in DB to a state valid for
// downgrades from nautilus.
int _open_db(bool create,
bool to_repair_db=false,
bool read_only = false);
- void _close_db();
+ void _close_db(bool read_only);
int _open_fm(KeyValueDB::Transaction t);
void _close_fm();
int _open_alloc();
while (1) {
if (writes_done == true)
break;
- fs.sync_metadata();
+ fs.sync_metadata(false);
sleep(1);
}
}
string file = "file.";
file.append(to_string(j));
fs.unlink(dir, file);
- fs.sync_metadata();
+ fs.sync_metadata(false);
}
ASSERT_EQ(0, fs.rmdir(dir));
- fs.sync_metadata();
+ fs.sync_metadata(false);
}
}
fs.compact_log();
string file = "file.";
file.append(to_string(j));
fs.unlink(dir, file);
- fs.sync_metadata();
+ fs.sync_metadata(false);
}
ASSERT_EQ(0, fs.rmdir(dir));
- fs.sync_metadata();
+ fs.sync_metadata(false);
}
}
fs.compact_log();