forked from vitalif/vitastor
Fix buffer overflows in the no_same_sector_overwrites mode
parent
5335c8de8e
commit
bec5f921a6
|
@ -89,12 +89,17 @@ int blockstore_impl_t::dequeue_rollback(blockstore_op_t *op)
|
|||
journal.crc32_last = je->crc32;
|
||||
if (cur_sector != journal.cur_sector)
|
||||
{
|
||||
if (cur_sector == -1)
|
||||
// Write 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);
|
||||
}
|
||||
}
|
||||
PRIV(op)->max_flushed_journal_sector = 1 + journal.cur_sector;
|
||||
PRIV(op)->pending_ops = s;
|
||||
PRIV(op)->op_state = 1;
|
||||
|
|
|
@ -121,12 +121,17 @@ int blockstore_impl_t::dequeue_stable(blockstore_op_t *op)
|
|||
journal.crc32_last = je->crc32;
|
||||
if (cur_sector != journal.cur_sector)
|
||||
{
|
||||
if (cur_sector == -1)
|
||||
// Write 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);
|
||||
}
|
||||
}
|
||||
PRIV(op)->max_flushed_journal_sector = 1 + journal.cur_sector;
|
||||
PRIV(op)->pending_ops = s;
|
||||
PRIV(op)->op_state = 1;
|
||||
|
|
|
@ -154,12 +154,17 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
|||
it++;
|
||||
if (cur_sector != journal.cur_sector)
|
||||
{
|
||||
if (cur_sector == -1)
|
||||
// Write 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);
|
||||
}
|
||||
}
|
||||
PRIV(op)->max_flushed_journal_sector = 1 + journal.cur_sector;
|
||||
PRIV(op)->pending_ops = s;
|
||||
PRIV(op)->op_state = SYNC_JOURNAL_WRITE_SENT;
|
||||
|
|
Loading…
Reference in New Issue