/*
- Copyright (C) 2010 Proxmox Server Solutions GmbH
+ Copyright (C) 2010 - 2020 Proxmox Server Solutions GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
#include <unistd.h>
#include <stdio.h>
+#include <inttypes.h>
#include <stdint.h>
#include <glib.h>
#include <string.h>
char tbuf[256];
strftime(tbuf, sizeof(tbuf), "%F %T", localtime(<));
printf("cpos %05d %08x %s", cpos, cur->uid, tbuf);
- printf(" %s{%016zX} %s[%s{%016zX}]: %s\n", node, cur->node_digest, tag, ident, cur->ident_digest, msg);
+ printf(" %s{%016" PRIX64 "} %s[%s{%016" PRIX64 "}]: %s\n", node, cur->node_digest, tag, ident, cur->ident_digest, msg);
}
while (cpos && (cpos <= clog->cpos || cpos > (clog->cpos + CLOG_MAX_ENTRY_SIZE))) {
clog_entry_t *cur = (clog_entry_t *)((char *)clog + cpos);
clog_dump_entry(cur, cpos);
+
+ // wrap-around has to land after initial position
+ if (cpos < cur->prev && cur->prev <= clog->cpos) {
+ break;
+ }
cpos = cur->prev;
}
}
guint count = 0;
while (cpos && (cpos <= clog->cpos || cpos > (clog->cpos + CLOG_MAX_ENTRY_SIZE))) {
clog_entry_t *cur = (clog_entry_t *)((char *)clog + cpos);
+
+ // wrap-around has to land after initial position
+ if (cpos < cur->prev && cur->prev <= clog->cpos) {
+ break;
+ }
cpos = cur->prev;
if (count >= max_entries)
clog_entry_t *new;
if ((new = clog_alloc_entry(clog, size)))
memcpy((char *)new + 8, (char *)entry + 8, size - 8);
-};
+}
uint32_t
clog_pack(
g_tree_insert(tree, cur, cur);
+ // wrap-around has to land after initial position
+ if (cpos < cur->prev && cur->prev <= clog->cpos) {
+ break;
+ }
+
cpos = cur->prev;
}
break;
}
- if (!cur->prev) {
+ // no previous entry or wrap-around into already overwritten entry
+ if (!cur->prev || (cpos[found] < cur->prev && cur->prev <= clog[found]->cpos)) {
cpos[found] = 0;
} else {
cpos[found] = cur->prev;
+ // wrap-around into current entry
if (!(cpos[found] <= clog[found]->cpos ||
cpos[found] > (clog[found]->cpos + CLOG_MAX_ENTRY_SIZE))) {
cpos[found] = 0;
if (dedup_lookup(cl->dedup, entry)) {
clog_copy(cl->base, entry);
} else {
- cfs_message("ignore duplicate"); // fixme remove
+ cfs_message("ignore insert of duplicate cluster log");
}
g_mutex_unlock(&cl->mutex);
-};
+}
void
clusterlog_add(