Lines Matching defs:file

1 /* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */
6 #include "file-dotlock.h"
18 struct mail_transaction_log_file *file)
20 i_assert(log->head != file);
22 file->refcount++;
23 log->head = file;
26 i_assert(log->files->next != NULL || log->files == file);
77 struct mail_transaction_log_file *file;
98 file = mail_transaction_log_file_alloc(log, log->filepath);
99 if ((ret = mail_transaction_log_file_open(file, &reason)) <= 0) {
100 /* leave the file for _create() */
101 log->open_file = file;
104 mail_transaction_log_set_head(log, file);
110 struct mail_transaction_log_file *file;
113 file = mail_transaction_log_file_alloc_in_memory(log);
114 mail_transaction_log_set_head(log, file);
118 file = mail_transaction_log_file_alloc(log, log->filepath);
120 /* remember what file we tried to open. if someone else created
121 a new file, use it instead of recreating it */
122 file->st_ino = log->open_file->st_ino;
123 file->st_dev = log->open_file->st_dev;
124 file->last_size = log->open_file->last_size;
125 file->last_mtime = log->open_file->last_mtime;
129 if (mail_transaction_log_file_create(file, reset) < 0) {
130 mail_transaction_log_file_free(&file);
134 mail_transaction_log_set_head(log, file);
165 struct mail_transaction_log_file *file;
170 .log file, so just start from scratch */
183 file = mail_transaction_log_file_alloc_in_memory(log);
184 mail_transaction_log_set_head(log, file);
191 struct mail_transaction_log_file *file;
195 for (file = log->files; file != NULL; file = file->next) {
196 if (file->hdr.indexid != log->index->indexid) {
197 mail_transaction_log_file_set_corrupted(file,
199 file->hdr.indexid, log->index->indexid);
213 struct mail_transaction_log_file *file, *next;
216 referenced an old file, it can still find the new files even if
218 for (file = log->files; file != NULL; file = next) {
219 next = file->next;
221 i_assert(file->refcount >= 0);
222 if (file->refcount > 0)
225 mail_transaction_log_file_free(&file);
228 for (; file != NULL; file = file->next) {
229 i_assert(!file->locked || file->refcount > 0);
236 struct mail_transaction_log_file *file = log->head;
238 if (file->need_rotate)
241 if (file->hdr.major_version < MAIL_TRANSACTION_LOG_MAJOR_VERSION ||
242 (file->hdr.major_version == MAIL_TRANSACTION_LOG_MAJOR_VERSION &&
243 file->hdr.minor_version < MAIL_TRANSACTION_LOG_MINOR_VERSION)) {
244 /* upgrade immediately to a new log file format */
248 if (file->sync_offset > log->index->optimization_set.log.max_size) {
249 /* file is too large, definitely rotate */
252 if (file->sync_offset < log->index->optimization_set.log.min_size) {
253 /* file is still too small */
257 return file->hdr.create_stamp <
263 struct mail_transaction_log_file *file;
271 file = mail_transaction_log_file_alloc_in_memory(log);
273 file->hdr.prev_file_seq = 0;
274 file->hdr.prev_file_offset = 0;
285 file = mail_transaction_log_file_alloc(log, path);
287 file->st_dev = st.st_dev;
288 file->st_ino = st.st_ino;
289 file->last_mtime = st.st_mtime;
290 file->last_size = st.st_size;
292 if ((ret = mail_transaction_log_file_create(file, reset)) < 0) {
293 mail_transaction_log_file_free(&file);
301 mail_transaction_log_file_free(&file);
304 i_assert(file->locked);
310 /* the newly created log file is already locked */
315 mail_transaction_log_set_head(log, file);
323 struct mail_transaction_log_file *file;
345 opening code figure out whether to create a new log file
356 the existing file has already been unlinked here
363 file = mail_transaction_log_file_alloc(log, log->filepath);
364 if (mail_transaction_log_file_open(file, reason_r) <= 0) {
365 mail_transaction_log_file_free(&file);
369 i_assert(!file->locked);
373 mail_transaction_log_set_head(log, file);
402 struct mail_transaction_log_file *file;
407 /* see if the .log file has been recreated */
410 file exists. */
440 for (file = log->files; file != NULL; file = file->next) {
441 if (file->hdr.file_seq == file_seq) {
442 *file_r = file;
445 if (file->hdr.file_seq > file_seq &&
446 file->hdr.prev_file_seq == 0) {
459 /* see if we have it in log.2 file */
460 file = mail_transaction_log_file_alloc(log, log->filepath2);
461 if ((ret = mail_transaction_log_file_open(file, reason_r)) <= 0) {
462 mail_transaction_log_file_free(&file);
467 if (file->hdr.file_seq != file_seq) {
469 file->hdr.file_seq);
473 *file_r = file;
480 struct mail_transaction_log_file *file;
485 /* we want to get the head file locked. this is a bit racy,
486 since by the time we have it locked a new log file may have been
489 creating new log file requires locking the head file, so if we
490 can lock it and don't see another file, we can be sure no-one is
495 file = log->head;
496 if (mail_transaction_log_file_lock(file) < 0)
499 file->refcount++;
501 if (--file->refcount == 0) {
502 mail_transaction_log_file_unlock(file, t_strdup_printf(
505 file = NULL;
508 if (ret == 0 && log->head == file) {
510 i_assert(file != NULL);
511 lock_secs = file->lock_created - lock_wait_started;
515 if (file != NULL) {
516 mail_transaction_log_file_unlock(file, t_strdup_printf(
525 i_warning("Locking transaction log file %s took %ld seconds (%s)",
592 struct mail_transaction_log_file *tail, *file = log->files;
594 for (tail = file; file->next != NULL; file = file->next) {
595 if (file->hdr.file_seq + 1 != file->next->hdr.file_seq)
596 tail = file->next;