From 6be6e0dfa2eaa0ab602e42401a64323972279a32 Mon Sep 17 00:00:00 2001 From: lihaoxiang Date: Fri, 2 Dec 2022 08:16:17 +0000 Subject: [PATCH] debugfs:fix repeated output problem with `logdump -O -n ` Signed-off-by: lihaoxiang --- ...ated-output-problem-with-logdump-O-n.patch | 75 +++++++++++++++++++ e2fsprogs.spec | 6 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 0018-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch diff --git a/0018-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch b/0018-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch new file mode 100644 index 0000000..a53456c --- /dev/null +++ b/0018-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch @@ -0,0 +1,75 @@ +From 7a0638733a43a4c3df275d2a9617e67a6f717556 Mon Sep 17 00:00:00 2001 +From: lihaoxiang +Date: Thu, 10 Nov 2022 17:09:20 +0800 +Subject: [PATCH] debugfs:fix repeated output problem with `logdump -O -n + ` + +Previously, patch 6e4cc3d5eeb2dfaa055e652b5390beaa6c3d05da introduces +the function of printing the specified number of logs. But there exists +a shortage when n is larger than the total number of logs, it dumped the +duplicated records circulately. + +For example, the disk sda only has three records, but using instruction logdump +-On5, it would output the result as follow: +---------------------------------------------------------------------- +Journal starts at block 1, transaction 6 +Found expected sequence 6, type 1 (descriptor block) at block 1 +Found expected sequence 6, type 2 (commit block) at block 4 +No magic number at block 5: end of journal. +Found sequence 2 (not 7) at block 7: end of journal. +Found expected sequence 2, type 2 (commit block) at block 7 +Found sequence 3 (not 8) at block 8: end of journal. +Found expected sequence 3, type 1 (descriptor block) at block 8 +Found sequence 3 (not 8) at block 15: end of journal. +Found expected sequence 3, type 2 (commit block) at block 15 +Found sequence 6 (not 9) at block 1: end of journal. <---------begin loop +Found expected sequence 6, type 1 (descriptor block) at block 1 +Found sequence 6 (not 9) at block 4: end of journal. +Found expected sequence 6, type 2 (commit block) at block 4 +Found sequence 2 (not 10) at block 7: end of journal. +Found expected sequence 2, type 2 (commit block) at block 7 +logdump: short read (read 0, expected 1024) while reading journal + +In this commit, we solve the problem above by exiting dumping if the +blocknr had already encountered, displayed the total number of logs +that the disk only possessed. + +Signed-off-by: lihaoxiang +--- + debugfs/logdump.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/debugfs/logdump.c b/debugfs/logdump.c +index df1526f..ebac195 100644 +--- a/debugfs/logdump.c ++++ b/debugfs/logdump.c +@@ -376,6 +376,7 @@ static void dump_journal(char *cmdname, FILE *out_file, + journal_header_t *header; + tid_t transaction; + unsigned int blocknr = 0; ++ unsigned int first_transaction_blocknr; + int fc_done; + __u64 total_len; + __u32 maxlen; +@@ -470,10 +471,19 @@ static void dump_journal(char *cmdname, FILE *out_file, + blocknr = 1; + } + ++ first_transaction_blocknr = blocknr; ++ + while (1) { + if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts)) + break; + ++ if ((blocknr == first_transaction_blocknr) && ++ ((cur_counts != 0) || (cur_counts == 0 && exist_no_magic)) && ++ dump_old && (dump_counts != -1)) { ++ fprintf(out_file, "Dump all %lld journal records.\n", cur_counts); ++ break; ++ } ++ + retval = read_journal_block(cmdname, source, + ((ext2_loff_t) blocknr) * blocksize, + buf, blocksize); +-- +2.37.0.windows.1 diff --git a/e2fsprogs.spec b/e2fsprogs.spec index ccca6fe..7371df5 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,6 +1,6 @@ Name: e2fsprogs Version: 1.46.5 -Release: 2 +Release: 3 Summary: Second extended file system management tools License: GPLv2+ and LGPLv2 and MIT URL: http://e2fsprogs.sourceforge.net/ @@ -24,6 +24,7 @@ Patch14: 0014-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch Patch15: 0015-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch Patch16: 0016-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch Patch17: 0017-unix_io.c-fix-deadlock-problem-in-unix_write_blk64.patch +Patch18: 0018-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch BuildRequires: gcc pkgconfig texinfo @@ -165,6 +166,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Fri Dec 2 2022 lihaoxiang - 1.46.5-3 +- debugfs: fix repeated output problem with `logdump -O -n ` + * Thu Dec 1 2022 Zhiqiang Liu - 1.46.5-2 - fix deadlock problem in unix_write_blk64 -- Gitee