From a5eda637077649c1eb5f2115f827dbf483ebb5ad Mon Sep 17 00:00:00 2001 From: Wenchao Hao Date: Sun, 7 Apr 2024 17:23:27 +0800 Subject: [PATCH] Backport patches from mainline Signed-off-by: Wenchao Hao --- ...hash_version-from-superblock-if-a-fi.patch | 49 ++++++++++++ ...debugfs-save-error-information-durin.patch | 76 +++++++++++++++++++ ...rect-I-O-when-reading-the-superblock.patch | 34 +++++++++ e2fsprogs.spec | 6 ++ 4 files changed, 165 insertions(+) create mode 100644 0012-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch create mode 100644 0013-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch create mode 100644 0014-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch diff --git a/0012-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch b/0012-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch new file mode 100644 index 0000000..61a9453 --- /dev/null +++ b/0012-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch @@ -0,0 +1,49 @@ +From 29d83fef9e6eab139516afe433c03d975e85c25b Mon Sep 17 00:00:00 2001 +From: Srivathsa Dara +Date: Thu, 24 Aug 2023 06:56:34 +0000 +Subject: [PATCH] debugfs: Use the hash_version from superblock if a file + system is opened + +The debugfs program's dx_hash command computes the hash for the given +filename, taking the hash_seed and hash_version (i.e hash algorithm) +as arguments. So the user has to refer to the superblock to get these +values used by the filesystem. So if debugfs has an opened file +system, use those values from the current file system. + +[ Fixed patch to avoid crashing when a file system is not opened. --TYT ] + +Signed-off-by: Srivathsa Dara +Link: https://lore.kernel.org/r/20230824065634.2662858-1-srivathsa.d.dara@oracle.com +Signed-off-by: Theodore Ts'o +--- + debugfs/htree.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/debugfs/htree.c b/debugfs/htree.c +index a9f9211b..a3e95ddb 100644 +--- a/debugfs/htree.c ++++ b/debugfs/htree.c +@@ -336,11 +336,18 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)), + errcode_t err; + int c; + int hash_version = 0; +- __u32 hash_seed[4]; ++ __u32 hash_seed[4] = { 0, }; + int hash_flags = 0; + const struct ext2fs_nls_table *encoding = NULL; + +- hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0; ++ if (current_fs) { ++ hash_seed[0] = current_fs->super->s_hash_seed[0]; ++ hash_seed[1] = current_fs->super->s_hash_seed[1]; ++ hash_seed[2] = current_fs->super->s_hash_seed[2]; ++ hash_seed[3] = current_fs->super->s_hash_seed[3]; ++ ++ hash_version = current_fs->super->s_def_hash_version; ++ } + + reset_getopt(); + while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) { +-- +2.32.0 + diff --git a/0013-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch b/0013-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch new file mode 100644 index 0000000..8a03642 --- /dev/null +++ b/0013-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch @@ -0,0 +1,76 @@ +From d5296ff0c665c1f957252ee18f824ad666a34b78 Mon Sep 17 00:00:00 2001 +From: Baokun Li +Date: Fri, 17 Feb 2023 18:09:22 +0800 +Subject: [PATCH] tune2fs/fuse2fs/debugfs: save error information during + journal replay + +Saving error information during journal replay, as in the kernel, +prevents information loss from making problems difficult to locate. +We save these error information until someone uses e2fsck to check +for and fix possible errors. + +Signed-off-by: Baokun Li +Reviewed-by: zhanchengbin +Reviewed-by: Jan Kara +Link: https://lore.kernel.org/r/20230217100922.588961-3-libaokun1@huawei.com +Signed-off-by: Theodore Ts'o +--- + debugfs/journal.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/debugfs/journal.c b/debugfs/journal.c +index 5bac0d3b..79e3fff8 100644 +--- a/debugfs/journal.c ++++ b/debugfs/journal.c +@@ -789,6 +789,8 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp) + char *fsname; + int fsflags; + int fsblocksize; ++ char *save; ++ __u16 s_error_state; + + if (!(fs->flags & EXT2_FLAG_RW)) + return EXT2_ET_FILE_RO; +@@ -808,6 +810,12 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp) + if (stats && stats->bytes_written) + kbytes_written = stats->bytes_written >> 10; + ++ save = malloc(EXT4_S_ERR_LEN); ++ if (save) ++ memcpy(save, ((char *) fs->super) + EXT4_S_ERR_START, ++ EXT4_S_ERR_LEN); ++ s_error_state = fs->super->s_state & EXT2_ERROR_FS; ++ + ext2fs_mmp_stop(fs); + fsname = fs->device_name; + fs->device_name = NULL; +@@ -818,11 +826,15 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp) + retval = ext2fs_open(fsname, fsflags, 0, fsblocksize, io_ptr, fsp); + ext2fs_free_mem(&fsname); + if (retval) +- return retval; ++ goto outfree; + + fs = *fsp; + fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; + fs->super->s_kbytes_written += kbytes_written; ++ fs->super->s_state |= s_error_state; ++ if (save) ++ memcpy(((char *) fs->super) + EXT4_S_ERR_START, save, ++ EXT4_S_ERR_LEN); + + /* Set the superblock flags */ + ext2fs_clear_recover(fs, recover_retval != 0); +@@ -832,6 +844,9 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp) + * the EXT2_ERROR_FS flag in the fs superblock if needed. + */ + retval = ext2fs_check_ext3_journal(fs); ++ ++outfree: ++ free(save); + return retval ? retval : recover_retval; + } + +-- +2.32.0 + diff --git a/0014-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch b/0014-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch new file mode 100644 index 0000000..4b6e0b9 --- /dev/null +++ b/0014-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch @@ -0,0 +1,34 @@ +From 43a498e938887956f393b5e45ea6ac79cc5f4b84 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 15 Jun 2023 00:17:01 -0400 +Subject: [PATCH] resize2fs: use Direct I/O when reading the superblock for + online resizes + +If the file system is mounted, the superblock can be changing while +resize2fs is trying to read the superblock, resulting in checksum +failures. One way of avoiding this problem is read the superblock +using Direct I/O, since the kernel makes sure that what gets written +to disk is self-consistent. + +Suggested-by: Krister Johansen +Signed-off-by: Theodore Ts'o +--- + resize/main.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/resize/main.c b/resize/main.c +index 94f5ec6d..f914c050 100644 +--- a/resize/main.c ++++ b/resize/main.c +@@ -409,6 +409,8 @@ int main (int argc, char ** argv) + + if (!(mount_flags & EXT2_MF_MOUNTED) && !print_min_size) + io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE; ++ if (mount_flags & EXT2_MF_MOUNTED) ++ io_flags |= EXT2_FLAG_DIRECT_IO; + + io_flags |= EXT2_FLAG_64BITS | EXT2_FLAG_THREADS; + if (undo_file) { +-- +2.32.0 + diff --git a/e2fsprogs.spec b/e2fsprogs.spec index 638c1c7..a9397a1 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -18,6 +18,9 @@ Patch8: 0008-e2fsprogs-add-sw64.patch Patch9: 0009-e2fsck-save-EXT2_ERROR_FS-flag-during-journal-replay.patch Patch10: 0010-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch Patch11: 0011-mke2fs.conf-remove-metadata_csum_seed-and-orphan_fil.patch +Patch12: 0012-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch +Patch13: 0013-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch +Patch14: 0014-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch BuildRequires: gcc pkgconfig texinfo BuildRequires: fuse-devel libblkid-devel libuuid-devel @@ -158,6 +161,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Sun Apr 7 2024 Zhiqiang Liu - 1.47.0-3 +- Backports from mainline + * Mon Jul 24 2023 Zhiqiang Liu - 1.47.0-2 - For openeuler 24.03 LTS, remove metadata_csum_seed and orphan_file to keep same with openeuler 22.03 LTS. -- Gitee