From 8bc61f001e564313c2ce5f2a664f9925ce177a85 Mon Sep 17 00:00:00 2001 From: lihaoxiang Date: Thu, 9 Feb 2023 04:47:38 -0500 Subject: [PATCH] Upstream patches regress for debugfs, tune2fs and mmp. Signed-off-by: lihaoxiang (cherry picked from commit 99d78650e51486d1ee5f753ab011b9220fc59841) --- ...ated-output-problem-with-logdump-O-n.patch | 76 +++++++++++++++++++ ...-wrong-comparison-in-ext2fs_mmp_stop.patch | 43 +++++++++++ e2fsprogs.spec | 7 +- 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 0049-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch create mode 100644 0050-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch diff --git a/0049-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch b/0049-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch new file mode 100644 index 0000000..2dc4708 --- /dev/null +++ b/0049-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch @@ -0,0 +1,76 @@ +From f547f088d46b3a0d1beb3a15d2bfa68e0fc5be19 Mon Sep 17 00:00:00 2001 +From: "lihaoxiang (F)" +Date: Tue, 15 Nov 2022 16:29:55 +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 +Signed-off-by: Theodore Ts'o +--- + debugfs/logdump.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/debugfs/logdump.c b/debugfs/logdump.c +index cf36e19..caf2d5c 100644 +--- a/debugfs/logdump.c ++++ b/debugfs/logdump.c +@@ -364,6 +364,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; + int64_t cur_counts = 0; + bool exist_no_magic = false; + +@@ -428,10 +429,18 @@ 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) && 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); +-- +1.8.3.1 + diff --git a/0050-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch b/0050-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch new file mode 100644 index 0000000..56979f6 --- /dev/null +++ b/0050-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch @@ -0,0 +1,43 @@ +From ffa6de1e3da4216a2ed6ec2890e16b22dc2ca40f Mon Sep 17 00:00:00 2001 +From: "lihaoxiang (F)" +Date: Tue, 29 Nov 2022 15:02:39 +0800 +Subject: [PATCH] mmp: fix wrong comparison in ext2fs_mmp_stop + +In our knowledge, ext2fs_mmp_stop use to process the rest of work +when mmp will finish. Critically, it must check if the mmp block is +not changed. But there exist an error in comparing the mmp and mmp_cmp. + +Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the +superblock of disk and it copy to mmp_buf if mmp_buf is not none +and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop +pass the no NULL pointer fs->mmp_buf which has possed the mmp info to +ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf +by fs->mmp_cmp so that loss the meaning of comparing themselves +after that and worse yet, couldn't judge whether the struct of mmp +has changed. + +In fact, we only need to modify the parameter to NULL pointer for +solving this problem. + +Signed-off-by: lihaoxiang +Signed-off-by: Theodore Ts'o +--- + lib/ext2fs/mmp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c +index 7970aac..1428970 100644 +--- a/lib/ext2fs/mmp.c ++++ b/lib/ext2fs/mmp.c +@@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs) + (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL)) + goto mmp_error; + +- retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf); ++ retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL); + if (retval) + goto mmp_error; + +-- +1.8.3.1 + diff --git a/e2fsprogs.spec b/e2fsprogs.spec index 0d5068e..f88829f 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,6 +1,6 @@ Name: e2fsprogs Version: 1.45.6 -Release: 14 +Release: 15 Summary: Second extended file system management tools License: GPLv2 and LGPLv2 and GPLv2+ URL: http://e2fsprogs.sourceforge.net/ @@ -55,6 +55,8 @@ Patch45: 0045-debugfs-teach-logdump-the-n-num_trans-option.patch Patch46: 0046-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch Patch47: 0047-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch Patch48: 0048-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch +Patch49: 0049-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch +Patch50: 0050-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch BuildRequires: gcc pkgconfig texinfo BuildRequires: fuse-devel libblkid-devel libuuid-devel @@ -176,6 +178,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Thu Feb 9 2023 lihaoxiang - 1.45.6-15 +- Upstream patches regress for debugfs, tune2fs and mmp. + * Fri Oct 14 2022 Zhiqiang Liu - 1.45.6-14 - tune2fs: fix one segfault problem -- Gitee