Merge pull request #24939 from msizanoen1/journal-realtime-enforce-consistency

journal: enforce strict consistency for realtime timestamps on write
This commit is contained in:
Daan De Meyer
2023-01-10 14:30:53 +01:00
committed by GitHub
4 changed files with 14 additions and 2 deletions
+4
View File
@@ -839,6 +839,10 @@ static bool shall_try_append_again(JournalFile *f, int r) {
log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Journal file is from the future, rotating.", f->path);
return true;
case -EREMCHG: /* Time jumped backwards relative to last journal entry */
log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Time jumped backwards relative to last journal entry, rotating.", f->path);
return true;
case -EAFNOSUPPORT:
log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"%s: underlying file system does not support memory mapping or another required file system feature.",
+2 -1
View File
@@ -524,7 +524,8 @@ int managed_journal_file_open_reliably(
-ESHUTDOWN, /* Already archived */
-EIO, /* IO error, including SIGBUS on mmap */
-EIDRM, /* File has been deleted */
-ETXTBSY)) /* File is from the future */
-ETXTBSY, /* File is from the future */
-EREMCHG)) /* Clock rolled back */
return r;
if ((open_flags & O_ACCMODE) == O_RDONLY)
+2 -1
View File
@@ -58,7 +58,8 @@ static void test_journal_flush(int argc, char *argv[]) {
assert_se(r >= 0 ||
IN_SET(r, -EBADMSG, /* corrupted file */
-EPROTONOSUPPORT, /* unsupported compression */
-EIO)); /* file rotated */
-EIO, /* file rotated */
-EREMCHG)); /* clock rollback */
if (++n >= 10000)
break;
+6
View File
@@ -2092,6 +2092,12 @@ static int journal_file_append_entry_internal(
assert(ts);
assert(items || n_items == 0);
if (ts->realtime < le64toh(f->header->tail_entry_realtime))
return log_debug_errno(SYNTHETIC_ERRNO(EREMCHG),
"Realtime timestamp %" PRIu64 " smaller than previous realtime "
"timestamp %" PRIu64 ", refusing entry.",
ts->realtime, le64toh(f->header->tail_entry_realtime));
osize = offsetof(Object, entry.items) + (n_items * journal_file_entry_item_size(f));
r = journal_file_append_object(f, OBJECT_ENTRY, osize, &o, &np);