加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-journal-Remove-entry-seqnum-revert-logic.patch 2.77 KB
一键复制 编辑 原始数据 按行查看 历史
From 06a0e8283ed87773795f28e58318d5d1b46b1088 Mon Sep 17 00:00:00 2001
From: Daan De Meyer <daan.j.demeyer@gmail.com>
Date: Fri, 12 Nov 2021 14:29:02 +0000
Subject: [PATCH] journal: Remove entry seqnum revert logic
This actually causes mismatches between the header tail entry seqnum
and the last entry seqnum since when we revert the header seqnum, we
don't remove the entry object we added. If adding the entry object
itself fails, we don't need to revert the seqnum since it's never
incremented so let's remove this logic alltogether.
(cherry picked from commit b41b682bd6f1290caa4220291b22cae317cb6413)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/06a0e8283ed87773795f28e58318d5d1b46b1088
---
src/libsystemd/sd-journal/journal-file.c | 32 ++----------------------
1 file changed, 2 insertions(+), 30 deletions(-)
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 2c17435de2..ae19c1c1f2 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -1021,30 +1021,6 @@ static uint64_t journal_file_entry_seqnum(
return ret;
}
-static void journal_file_revert_entry_seqnum(
- JournalFile *f,
- uint64_t *seqnum,
- uint64_t revert_seqnum) {
-
- assert(f);
- assert(f->header);
-
- if (revert_seqnum == 0) /* sequence number 0? can't go back */
- return;
-
- /* Undoes the effect of journal_file_entry_seqnum() above: if we fail to append an entry to a file,
- * let's revert the seqnum we were about to use, so that we can use it on the next entry. */
-
- if (le64toh(f->header->tail_entry_seqnum) == revert_seqnum)
- f->header->tail_entry_seqnum = htole64(revert_seqnum - 1);
-
- if (le64toh(f->header->head_entry_seqnum) == revert_seqnum)
- f->header->head_entry_seqnum = 0;
-
- if (seqnum && *seqnum == revert_seqnum)
- *seqnum = revert_seqnum - 1;
-}
-
int journal_file_append_object(
JournalFile *f,
ObjectType type,
@@ -2004,12 +1980,12 @@ static int journal_file_append_entry_internal(
#if HAVE_GCRYPT
r = journal_file_hmac_put_object(f, OBJECT_ENTRY, o, np);
if (r < 0)
- goto fail;
+ return r;
#endif
r = journal_file_link_entry(f, o, np);
if (r < 0)
- goto fail;
+ return r;
if (ret)
*ret = o;
@@ -2017,10 +1993,6 @@ static int journal_file_append_entry_internal(
if (ret_offset)
*ret_offset = np;
- return 0;
-
-fail:
- journal_file_revert_entry_seqnum(f, seqnum, le64toh(o->entry.seqnum));
return r;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化