|
|
|
@ -120,21 +120,21 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op) |
|
|
|
|
// Prepare and submit journal entries
|
|
|
|
|
auto it = PRIV(op)->sync_big_writes.begin(); |
|
|
|
|
int s = 0, cur_sector = -1; |
|
|
|
|
if ((journal_block_size - journal.in_sector_pos) < sizeof(journal_entry_big_write) && |
|
|
|
|
journal.sector_info[journal.cur_sector].dirty) |
|
|
|
|
{ |
|
|
|
|
PRIV(op)->min_flushed_journal_sector = 1 + journal.cur_sector; |
|
|
|
|
prepare_journal_sector_write(journal, journal.cur_sector, sqe[s++], cb); |
|
|
|
|
cur_sector = ((journal.cur_sector + 1) % journal.sector_count); |
|
|
|
|
} |
|
|
|
|
while (it != PRIV(op)->sync_big_writes.end()) |
|
|
|
|
{ |
|
|
|
|
if (!journal.entry_fits(sizeof(journal_entry_big_write)) && |
|
|
|
|
journal.sector_info[journal.cur_sector].dirty) |
|
|
|
|
{ |
|
|
|
|
if (cur_sector == -1) |
|
|
|
|
PRIV(op)->min_flushed_journal_sector = 1 + journal.cur_sector; |
|
|
|
|
prepare_journal_sector_write(journal, journal.cur_sector, sqe[s++], cb); |
|
|
|
|
cur_sector = journal.cur_sector; |
|
|
|
|
} |
|
|
|
|
journal_entry_big_write *je = (journal_entry_big_write*)prefill_single_journal_entry( |
|
|
|
|
journal, (dirty_db[*it].state & BS_ST_INSTANT) ? JE_BIG_WRITE_INSTANT : JE_BIG_WRITE, |
|
|
|
|
sizeof(journal_entry_big_write) |
|
|
|
|
); |
|
|
|
|
dirty_db[*it].journal_sector = journal.sector_info[journal.cur_sector].offset; |
|
|
|
|
journal.sector_info[journal.cur_sector].dirty = false; |
|
|
|
|
journal.used_sectors[journal.sector_info[journal.cur_sector].offset]++; |
|
|
|
|
#ifdef BLOCKSTORE_DEBUG |
|
|
|
|
printf( |
|
|
|
@ -151,19 +151,11 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op) |
|
|
|
|
je->crc32 = je_crc32((journal_entry*)je); |
|
|
|
|
journal.crc32_last = je->crc32; |
|
|
|
|
it++; |
|
|
|
|
if (cur_sector != journal.cur_sector) |
|
|
|
|
{ |
|
|
|
|
// Write the previous sector. We should write the sector only after filling it,
|
|
|
|
|
// because otherwise we'll write a lot more sectors in the "no_same_sector_overwrite" mode
|
|
|
|
|
if (cur_sector != -1) |
|
|
|
|
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb); |
|
|
|
|
else |
|
|
|
|
PRIV(op)->min_flushed_journal_sector = 1 + journal.cur_sector; |
|
|
|
|
cur_sector = journal.cur_sector; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cur_sector != -1) |
|
|
|
|
prepare_journal_sector_write(journal, cur_sector, sqe[s++], cb); |
|
|
|
|
prepare_journal_sector_write(journal, journal.cur_sector, sqe[s++], cb); |
|
|
|
|
assert(s == space_check.sectors_required); |
|
|
|
|
if (cur_sector == -1) |
|
|
|
|
PRIV(op)->min_flushed_journal_sector = 1 + journal.cur_sector; |
|
|
|
|
PRIV(op)->max_flushed_journal_sector = 1 + journal.cur_sector; |
|
|
|
|
PRIV(op)->pending_ops = s; |
|
|
|
|
PRIV(op)->op_state = SYNC_JOURNAL_WRITE_SENT; |
|
|
|
|