X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournal-file.c;h=977cfa1010f8a57ae057a4b3412e65c907368d0a;hb=4bbdcdb301f8ef6f8b9e943210ab61250003c517;hp=45aab0e54a0eacfb2b3923a6c1ae2c8e50e66f0f;hpb=6c8a39b883d77a1e04f2947a2e890dfb8dd51d04;p=elogind.git diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 45aab0e54..977cfa101 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -138,6 +138,9 @@ static int journal_file_refresh_header(JournalFile *f) { f->header->boot_id = boot_id; f->header->state = STATE_ONLINE; + + __sync_synchronize(); + return 0; } @@ -293,6 +296,15 @@ static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_ assert(wt >= 0); assert(wt < _WINDOW_MAX); + if (offset + size > (uint64_t) f->last_stat.st_size) { + /* Hmm, out of range? Let's refresh the fstat() data + * first, before we trust that check. */ + + if (fstat(f->fd, &f->last_stat) < 0 || + offset + size > (uint64_t) f->last_stat.st_size) + return -EADDRNOTAVAIL; + } + w = f->windows + wt; if (_likely_(w->ptr && @@ -328,9 +340,6 @@ static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_ } else delta = 0; - if (offset > (uint64_t) f->last_stat.st_size) - return -EADDRNOTAVAIL; - if (offset + size > (uint64_t) f->last_stat.st_size) size = PAGE_ALIGN((uint64_t) f->last_stat.st_size - offset); @@ -898,6 +907,8 @@ static int journal_file_link_entry(JournalFile *f, Object *o, uint64_t offset) { assert(offset > 0); assert(o->object.type == OBJECT_ENTRY); + __sync_synchronize(); + /* Link up the entry itself */ r = link_entry_into_array(f, &f->header->entry_array_offset,