!202 回合上游社区补丁,修复debugfs中执行logdump死循环问题

From: @jinzig 
Reviewed-by: @wenchao-hao, @swf504 
Signed-off-by: @swf504
This commit is contained in:
openeuler-ci-bot 2024-05-06 01:49:55 +00:00 committed by Gitee
commit 76cf90331a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,74 @@
From 272173a300822b5cfe19bef597609523baab0c66 Mon Sep 17 00:00:00 2001
From: Wenchao Hao <haowenchao2@huawei.com>
Date: Fri, 17 Nov 2023 18:23:15 +0800
Subject: [PATCH 1/1] debugfs: fix infinite loop while dumping the journal
There are 2 scenarios which would trigger infinite loop:
1. None log is recorded, then dumplog with "-n", for example:
debugfs -R "logdump -O -n 10" /dev/xxx
while /dev/xxx has no valid log recorded.
2. The log area is full and cycle write is triggered, then dumplog with
debugfs -R "logdump -aOS" /dev/xxx
This patch add a new flag "wrapped_flag" to mark if logdump has
reached to tail of logarea set in macro WRAP().
If wrapped_flag is true, and we comes to first_transaction_blocknr
again, just break the logdump loop.
[ Renamed reverse_flag to wrapped_flag to make it clearer what it is. -- TYT ]
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20231117102315.2431846-1-haowenchao2@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
debugfs/logdump.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index b600228e..c4d46648 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -52,6 +52,7 @@ static int64_t dump_counts;
static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
static unsigned int group_to_dump, inode_offset_to_dump;
static ext2_ino_t inode_to_dump;
+static bool wrapped_flag;
struct journal_source
{
@@ -80,8 +81,10 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize,
static void do_hexdump (FILE *, char *, int);
#define WRAP(jsb, blocknr, maxlen) \
- if (blocknr >= (maxlen)) \
- blocknr -= (maxlen - be32_to_cpu((jsb)->s_first));
+ if (blocknr >= (maxlen)) { \
+ blocknr -= (maxlen - be32_to_cpu((jsb)->s_first)); \
+ wrapped_flag = true; \
+ }
void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
void *infop EXT2FS_ATTR((unused)))
@@ -115,6 +118,7 @@ void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
inode_block_to_dump = ANY_BLOCK;
inode_to_dump = -1;
dump_counts = -1;
+ wrapped_flag = false;
reset_getopt();
while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) {
@@ -477,8 +481,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
break;
- if ((blocknr == first_transaction_blocknr) &&
- (cur_counts != 0) && dump_old && (dump_counts != -1)) {
+ if ((blocknr == first_transaction_blocknr) && dump_old && wrapped_flag) {
fprintf(out_file, "Dump all %lld journal records.\n",
(long long) cur_counts);
break;
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: e2fsprogs Name: e2fsprogs
Version: 1.47.0 Version: 1.47.0
Release: 2 Release: 3
Summary: Second extended file system management tools Summary: Second extended file system management tools
License: GPLv2+ and LGPLv2 and MIT License: GPLv2+ and LGPLv2 and MIT
URL: http://e2fsprogs.sourceforge.net/ URL: http://e2fsprogs.sourceforge.net/
@ -18,6 +18,7 @@ Patch8: 0008-e2fsprogs-add-sw64.patch
Patch9: 0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch Patch9: 0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch
Patch10: 0010-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch Patch10: 0010-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
Patch11: 0011-mke2fs.conf-remove-metadata_csum_seed-and-orphan_fil.patch Patch11: 0011-mke2fs.conf-remove-metadata_csum_seed-and-orphan_fil.patch
Patch12: 0012-debugfs-fix-infinite-loop-while-dumping-the-journal.patch
BuildRequires: gcc pkgconfig texinfo BuildRequires: gcc pkgconfig texinfo
BuildRequires: fuse-devel libblkid-devel libuuid-devel BuildRequires: fuse-devel libblkid-devel libuuid-devel
@ -158,6 +159,10 @@ exit 0
%{_mandir}/man8/* %{_mandir}/man8/*
%changelog %changelog
* Thu Apr 18 2024 jinzhiguang <jinzhiguang@kylinos.cn> - 1.47.0-3
- Upstream patches regress for debugfs.
Fix infinite loop while dumping the journal.
* Mon Jul 24 2023 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.47.0-2 * Mon Jul 24 2023 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.47.0-2
- For openeuler 24.03 LTS, remove metadata_csum_seed and orphan_file - For openeuler 24.03 LTS, remove metadata_csum_seed and orphan_file
to keep same with openeuler 22.03 LTS. to keep same with openeuler 22.03 LTS.