forked from vitalif/vitastor
Allow to start the OSD just to flush the journal completely
parent
ec90fe6ec1
commit
6909807068
|
@ -17,8 +17,8 @@ journal_flusher_t::journal_flusher_t(blockstore_impl_t *bs)
|
||||||
// FIXME: allow to configure flusher_start_threshold and journal_trim_interval
|
// FIXME: allow to configure flusher_start_threshold and journal_trim_interval
|
||||||
flusher_start_threshold = bs->journal_block_size / sizeof(journal_entry_stable);
|
flusher_start_threshold = bs->journal_block_size / sizeof(journal_entry_stable);
|
||||||
journal_trim_interval = 512;
|
journal_trim_interval = 512;
|
||||||
journal_trim_counter = 0;
|
journal_trim_counter = bs->journal.flush_journal ? 1 : 0;
|
||||||
trim_wanted = 0;
|
trim_wanted = bs->journal.flush_journal ? 1 : 0;
|
||||||
journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->journal_block_size);
|
journal_superblock = bs->journal.inmemory ? bs->journal.buffer : memalign_or_die(MEM_ALIGNMENT, bs->journal_block_size);
|
||||||
co = new journal_flusher_co[max_flusher_count];
|
co = new journal_flusher_co[max_flusher_count];
|
||||||
for (int i = 0; i < max_flusher_count; i++)
|
for (int i = 0; i < max_flusher_count; i++)
|
||||||
|
@ -626,6 +626,12 @@ resume_1:
|
||||||
#endif
|
#endif
|
||||||
flusher->trimming = false;
|
flusher->trimming = false;
|
||||||
}
|
}
|
||||||
|
if (bs->journal.flush_journal && !flusher->flush_queue.size())
|
||||||
|
{
|
||||||
|
assert(bs->journal.used_start == bs->journal.next_free);
|
||||||
|
printf("Journal flushed\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// All done
|
// All done
|
||||||
flusher->active_flushers--;
|
flusher->active_flushers--;
|
||||||
|
|
|
@ -92,10 +92,23 @@ void blockstore_impl_t::loop()
|
||||||
{
|
{
|
||||||
delete journal_init_reader;
|
delete journal_init_reader;
|
||||||
journal_init_reader = NULL;
|
journal_init_reader = NULL;
|
||||||
initialized = 10;
|
if (journal.flush_journal)
|
||||||
|
initialized = 3;
|
||||||
|
else
|
||||||
|
initialized = 10;
|
||||||
ringloop->wakeup();
|
ringloop->wakeup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (initialized == 3)
|
||||||
|
{
|
||||||
|
if (readonly)
|
||||||
|
{
|
||||||
|
printf("Can't flush the journal in readonly mode\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
flusher->loop();
|
||||||
|
ringloop->submit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,7 @@ struct journal_t
|
||||||
int fd;
|
int fd;
|
||||||
uint64_t device_size;
|
uint64_t device_size;
|
||||||
bool inmemory = false;
|
bool inmemory = false;
|
||||||
|
bool flush_journal = false;
|
||||||
void *buffer = NULL;
|
void *buffer = NULL;
|
||||||
|
|
||||||
uint64_t block_size;
|
uint64_t block_size;
|
||||||
|
|
|
@ -42,6 +42,11 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config)
|
||||||
{
|
{
|
||||||
disable_flock = true;
|
disable_flock = true;
|
||||||
}
|
}
|
||||||
|
if (config["flush_journal"] == "true" || config["flush_journal"] == "1" || config["flush_journal"] == "yes")
|
||||||
|
{
|
||||||
|
// Only flush journal and exit
|
||||||
|
journal.flush_journal = true;
|
||||||
|
}
|
||||||
if (config["immediate_commit"] == "all")
|
if (config["immediate_commit"] == "all")
|
||||||
{
|
{
|
||||||
immediate_commit = IMMEDIATE_ALL;
|
immediate_commit = IMMEDIATE_ALL;
|
||||||
|
@ -87,7 +92,7 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config)
|
||||||
{
|
{
|
||||||
max_flusher_count = 256;
|
max_flusher_count = 256;
|
||||||
}
|
}
|
||||||
if (!min_flusher_count)
|
if (!min_flusher_count || journal.flush_journal)
|
||||||
{
|
{
|
||||||
min_flusher_count = 1;
|
min_flusher_count = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue