Lines Matching defs:log

13 #include "mail-transaction-log-private.h"
16 #define MEMORY_LOG_NAME "(in-memory transaction log file)"
27 mail_index_file_set_syscall_error(file->log->index,
39 file->log->index->readonly)
42 /* indexid=0 marks the log file as corrupted. we opened the file with
47 mail_index_file_set_syscall_error(file->log->index,
52 mail_index_file_set_syscall_error(file->log->index,
58 mail_index_file_set_syscall_error(file->log->index,
75 mail_index_set_error(file->log->index,
76 "Corrupted transaction log file %s seq %u: %s "
85 mail_transaction_log_file_alloc(struct mail_transaction_log *log,
91 file->log = log;
107 for (p = &file->log->files; *p != NULL; p = &(*p)->next) {
114 if (file == file->log->head)
115 file->log->head = NULL;
138 struct mail_transaction_log *log = file->log;
139 struct mail_index_map *map = log->index->map;
147 /* we can get a valid log offset from index file. initialize
148 sync_offset from it so we don't have to read the whole log
154 mail_index_set_error(log->index,
156 log->index->filepath);
169 mail_index_set_error(log->index,
171 log->index->filepath);
179 if (file->hdr.file_seq == log->index->map->hdr.log_file_seq) {
181 log->index->map->hdr.log_file_tail_offset;
200 for (p = &file->log->files; *p != NULL; p = &(*p)->next) {
219 mail_transaction_log_init_hdr(struct mail_transaction_log *log,
222 struct mail_index *index = log->index;
231 hdr->indexid = log->index->indexid;
244 /* if we got here from mapping, the .log file is
259 /* modseq tracking in log files is required for many reasons
265 if (log->head != NULL) {
268 happen to replace the same log file. */
269 for (file = log->head->next; file != NULL; file = file->next) {
274 if (hdr->file_seq <= log->head->hdr.file_seq) {
276 hdr->file_seq = log->head->hdr.file_seq+1;
278 if (hdr->initial_modseq < log->head->sync_highest_modseq) {
280 hdr->initial_modseq = log->head->sync_highest_modseq;
287 mail_transaction_log_file_alloc_in_memory(struct mail_transaction_log *log)
291 file = mail_transaction_log_file_alloc(log, MEMORY_LOG_NAME);
292 if (mail_transaction_log_init_hdr(log, &file->hdr) < 0) {
310 if (file->log->dotlock_count > 0)
313 mail_transaction_log_get_dotlock_set(file->log, &dotlock_set);
315 &file->log->dotlock);
318 file->log->dotlock_count++;
328 mail_index_set_error(file->log->index,
330 "dotlock for transaction log file %s",
332 file->log->index->index_lock_timeout = TRUE;
341 if (--file->log->dotlock_count > 0)
344 ret = file_dotlock_delete(&file->log->dotlock);
351 mail_index_set_error(file->log->index,
352 "Dotlock was lost for transaction log file %s",
372 if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK)
375 if (file->log->index->readonly) {
376 mail_index_set_error(file->log->index,
384 file->log->index->max_lock_timeout_secs);
385 ret = mail_index_lock_fd(file->log->index, file->filepath, file->fd,
398 mail_index_set_error(file->log->index,
400 "transaction log file %s%s",
402 file_lock_find(file->fd, file->log->index->lock_method, F_WRLCK));
403 file->log->index->index_lock_timeout = TRUE;
423 i_warning("Transaction log file %s was locked for %u seconds (%s)",
427 if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) {
446 /* just read the entire transaction log to memory.
460 since older versions of the log format used smaller headers. */
486 if (strcmp(file->filepath, file->log->head->filepath) != 0) {
488 changes from .log in case we're somehow wrong */
496 mail_index_set_error(file->log->index,
497 "Transaction log %s: "
498 "duplicate transaction log sequence (%u)",
543 mail_index_set_error(file->log->index,
546 file->log->index->filepath);
565 mail_index_set_error(file->log->index,
566 "Transaction log file %s: marked corrupted",
570 if (file->hdr.indexid != file->log->index->indexid) {
571 if (file->log->index->indexid != 0 &&
572 !file->log->index->initial_create) {
577 file->log->index->indexid, file->hdr.indexid);
581 /* creating index file. since transaction log is created
584 file->log->index->indexid = file->hdr.indexid;
588 opened. it shouldn't happen unless the old log file was
590 for (f = file->log->files; f != NULL; f = f->next) {
592 if (strcmp(f->filepath, f->log->head->filepath) != 0) {
593 /* old "f" is the .log.2 */
596 /* new "file" is probably the .log.2 */
630 for (tmp = file->log->files; tmp != NULL; tmp = tmp->next) {
684 struct mail_index *index = file->log->index;
691 need_lock = file->log->head != NULL && file->log->head->locked;
698 if (file->log->nfs_flush) {
700 only to fix broken log files. we don't bother flushing
705 /* log creation is locked now - see if someone already created it.
706 note that if we're rotating, we need to keep the log locked until
722 but not when we're replacing a broken log file */
758 if (mail_transaction_log_init_hdr(file->log, &file->hdr) < 0)
779 if (file->log->index->fsync_mode == FSYNC_MODE_ALWAYS) {
802 /* keep two log files */
806 file_dotlock_replace(). during that time the log file
817 second log file and we're going to overwrite this
820 /* NOTE: here's a race condition where both .log and .log.2
844 struct mail_index *index = file->log->index;
852 if (file->log->index->readonly) {
854 "Can't create log file %s: Index is read-only",
861 "Can't create log file %s: Index is marked corrupted",
866 mail_transaction_log_get_dotlock_set(file->log, &new_dotlock_set);
895 struct mail_index *index = file->log->index;
926 /* probably our already opened .log file has been
927 renamed to .log.2 and we're trying to reopen it.
928 also possible that hit a race condition where .log
929 and .log.2 are linked. */
1014 /* Hide internal flags from modseqs if the log file's version
1183 "Transaction log corrupted unexpectedly at "
1231 "Failed to map transaction log %s for getting modseq "
1272 mail_index_set_error(file->log->index,
1273 "Failed to map transaction log %s for getting offset "
1288 mail_index_set_error(file->log->index,
1339 mail_index_set_error(file->log->index,
1340 "%s: Transaction log modseq tracking is corrupted - fixing",
1353 file->log->index->need_recreate = TRUE;
1395 file->log->index->index_deleted = TRUE;
1396 file->log->index->index_delete_requested = FALSE;
1402 file->log->index->index_deleted = FALSE;
1403 file->log->index->index_delete_requested = FALSE;
1448 "log file shrank (%"PRIuUOFF_T" < %"PRIuUOFF_T")",
1510 be updated unless we've locked the log. */
1517 mail_index_flush_read_cache(file->log->index, file->filepath,
1525 "Invalid transaction log size "
1527 file->log->head->hdr.prev_file_offset, file->filepath);
1563 /* log file was deleted in NFS server, fail silently */
1599 /* log file was deleted in NFS server, fail silently */
1611 const struct mail_index_header *hdr = &file->log->index->map->hdr;
1617 /* we already have a newer log file which says that we haven't
1643 refreshing the log. */
1644 if (file->log->nfs_flush && nfs_flush) {
1666 else if (file->log->nfs_flush && !nfs_flush &&
1853 if (file->locked_sync_offset_updated && file == file->log->head &&
1878 /* we had moved the log to memory but failed to read
1879 the beginning of the log file */
1880 *reason_r = "Beginning of the log isn't available";
1896 if ((file->log->index->flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) == 0)
1936 /* we don't have the full log in the memory. read it. */
1939 mail_index_set_error(file->log->index,
1950 file->filepath = i_strdup(file->log->filepath);