forked from vitalif/vitastor
Refuse to start with old journal version
parent
c72fddd714
commit
f684d9101a
|
@ -602,6 +602,7 @@ resume_1:
|
||||||
.size = sizeof(journal_entry_start),
|
.size = sizeof(journal_entry_start),
|
||||||
.reserved = 0,
|
.reserved = 0,
|
||||||
.journal_start = new_trim_pos,
|
.journal_start = new_trim_pos,
|
||||||
|
.version = JOURNAL_VERSION,
|
||||||
};
|
};
|
||||||
((journal_entry_start*)flusher->journal_superblock)->crc32 = je_crc32((journal_entry*)flusher->journal_superblock);
|
((journal_entry_start*)flusher->journal_superblock)->crc32 = je_crc32((journal_entry*)flusher->journal_superblock);
|
||||||
data->iov = (struct iovec){ flusher->journal_superblock, bs->journal_block_size };
|
data->iov = (struct iovec){ flusher->journal_superblock, bs->journal_block_size };
|
||||||
|
|
|
@ -231,7 +231,7 @@ resume_1:
|
||||||
wait_state = 1;
|
wait_state = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (iszero((uint64_t*)submitted_buf, 3))
|
if (iszero((uint64_t*)submitted_buf, bs->journal.block_size))
|
||||||
{
|
{
|
||||||
// Journal is empty
|
// Journal is empty
|
||||||
// FIXME handle this wrapping to journal_block_size better (maybe)
|
// FIXME handle this wrapping to journal_block_size better (maybe)
|
||||||
|
@ -246,6 +246,7 @@ resume_1:
|
||||||
.size = sizeof(journal_entry_start),
|
.size = sizeof(journal_entry_start),
|
||||||
.reserved = 0,
|
.reserved = 0,
|
||||||
.journal_start = bs->journal.block_size,
|
.journal_start = bs->journal.block_size,
|
||||||
|
.version = JOURNAL_VERSION,
|
||||||
};
|
};
|
||||||
((journal_entry_start*)submitted_buf)->crc32 = je_crc32((journal_entry*)submitted_buf);
|
((journal_entry_start*)submitted_buf)->crc32 = je_crc32((journal_entry*)submitted_buf);
|
||||||
if (bs->readonly)
|
if (bs->readonly)
|
||||||
|
@ -296,11 +297,21 @@ resume_1:
|
||||||
je_start = (journal_entry_start*)submitted_buf;
|
je_start = (journal_entry_start*)submitted_buf;
|
||||||
if (je_start->magic != JOURNAL_MAGIC ||
|
if (je_start->magic != JOURNAL_MAGIC ||
|
||||||
je_start->type != JE_START ||
|
je_start->type != JE_START ||
|
||||||
je_start->size != sizeof(journal_entry_start) ||
|
je_crc32((journal_entry*)je_start) != je_start->crc32 ||
|
||||||
je_crc32((journal_entry*)je_start) != je_start->crc32)
|
je_start->size != sizeof(journal_entry_start) && je_start->size != JE_START_LEGACY_SIZE)
|
||||||
{
|
{
|
||||||
// Entry is corrupt
|
// Entry is corrupt
|
||||||
throw std::runtime_error("first entry of the journal is corrupt");
|
fprintf(stderr, "First entry of the journal is corrupt\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (je_start->size == JE_START_LEGACY_SIZE || je_start->version != JOURNAL_VERSION)
|
||||||
|
{
|
||||||
|
fprintf(
|
||||||
|
stderr, "The code only supports journal version %d, but it is %lu on disk."
|
||||||
|
" Please use the previous version to flush the journal before upgrading OSD\n",
|
||||||
|
JOURNAL_VERSION, je_start->size == JE_START_LEGACY_SIZE ? 0 : je_start->version
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
next_free = journal_pos = bs->journal.used_start = je_start->journal_start;
|
next_free = journal_pos = bs->journal.used_start = je_start->journal_start;
|
||||||
if (!bs->journal.inmemory)
|
if (!bs->journal.inmemory)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#define MIN_JOURNAL_SIZE 4*1024*1024
|
#define MIN_JOURNAL_SIZE 4*1024*1024
|
||||||
#define JOURNAL_MAGIC 0x4A33
|
#define JOURNAL_MAGIC 0x4A33
|
||||||
|
#define JOURNAL_VERSION 1
|
||||||
#define JOURNAL_BUFFER_SIZE 4*1024*1024
|
#define JOURNAL_BUFFER_SIZE 4*1024*1024
|
||||||
|
|
||||||
// We reserve some extra space for future stabilize requests during writes
|
// We reserve some extra space for future stabilize requests during writes
|
||||||
|
@ -37,7 +38,9 @@ struct __attribute__((__packed__)) journal_entry_start
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t reserved;
|
uint32_t reserved;
|
||||||
uint64_t journal_start;
|
uint64_t journal_start;
|
||||||
|
uint64_t version;
|
||||||
};
|
};
|
||||||
|
#define JE_START_LEGACY_SIZE 24
|
||||||
|
|
||||||
struct __attribute__((__packed__)) journal_entry_small_write
|
struct __attribute__((__packed__)) journal_entry_small_write
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue