diff --git a/e2fsprogs-1.45.6-Makefile.in-Disable-e2scrub.patch b/0001-Makefile.in-Disable-e2scrub.patch similarity index 77% rename from e2fsprogs-1.45.6-Makefile.in-Disable-e2scrub.patch rename to 0001-Makefile.in-Disable-e2scrub.patch index 0d312422e1b3f72e7f2da94c0e25c9ca07464d57..f00373da67e47c110b2f0c285b062736227360bb 100644 --- a/e2fsprogs-1.45.6-Makefile.in-Disable-e2scrub.patch +++ b/0001-Makefile.in-Disable-e2scrub.patch @@ -1,21 +1,22 @@ -From 06116f6d053e398d13634df911bcb105d0fb2416 Mon Sep 17 00:00:00 2001 +From f9dacf411f58ab0ef50f23d760b575472c1245e4 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Sun, 15 Dec 2019 12:42:28 +0100 -Subject: [PATCH 1/7] Makefile.in: Disable e2scrub +Subject: [PATCH 01/10] Makefile.in: Disable e2scrub e2scrub system is still new and we're not ready to support it yet, so just disbale it and not even build it. Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- Makefile.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in -index b951c017..34e2048d 100644 +index d412dfbc..08c536c5 100644 --- a/Makefile.in +++ b/Makefile.in -@@ -13,7 +13,6 @@ INSTALL = @INSTALL@ +@@ -14,7 +14,6 @@ MKDIR_P = @MKDIR_P@ @DEBUGFS_CMT@DEBUGFS_DIR= debugfs @UUID_CMT@UUID_LIB_SUBDIR= lib/uuid @BLKID_CMT@BLKID_LIB_SUBDIR= lib/blkid @@ -23,9 +24,9 @@ index b951c017..34e2048d 100644 @ALL_CMT@SUPPORT_LIB_SUBDIR= lib/support @ALL_CMT@E2P_LIB_SUBDIR= lib/e2p @ALL_CMT@EXT2FS_LIB_SUBDIR= lib/ext2fs -@@ -21,8 +20,7 @@ INSTALL = @INSTALL@ +@@ -22,8 +21,7 @@ MKDIR_P = @MKDIR_P@ LIB_SUBDIRS=lib/et lib/ss $(E2P_LIB_SUBDIR) $(UUID_LIB_SUBDIR) \ - $(BLKID_LIB_SUBDIR) $(SUPPORT_LIB_SUBDIR) $(EXT2FS_LIB_SUBDIR) intl + $(BLKID_LIB_SUBDIR) $(SUPPORT_LIB_SUBDIR) $(EXT2FS_LIB_SUBDIR) -PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po \ - $(E2SCRUB_DIR) @@ -34,5 +35,5 @@ index b951c017..34e2048d 100644 SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch b/0002-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch similarity index 79% rename from e2fsprogs-1.45.6-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch rename to 0002-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch index 8da372ea76d8e65564b50f88caf9be35adb58006..c93ce348b29abcbfb456b3bbb51ee15dca3f2651 100644 --- a/e2fsprogs-1.45.6-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch +++ b/0002-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch @@ -1,10 +1,12 @@ -From f2bb71bdbedf33f4fae4e1402ec23fe58eece1a7 Mon Sep 17 00:00:00 2001 +From 58e1f8849df0eec59d0615509f51d1052f71c0e9 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Sun, 15 Dec 2019 14:39:46 +0100 -Subject: [PATCH 2/7] Revert "fuse2fs: install fuse2fs in /usr/bin instead of +Subject: [PATCH 02/10] Revert "fuse2fs: install fuse2fs in /usr/bin instead of /usr/sbin" This reverts commit b71150355dca5409cf8e82a7e715e459a795bbf8. + +Signed-off-by: Joseph Qi --- debian/fuse2fs.install | 2 +- misc/Makefile.in | 4 ++-- @@ -19,10 +21,10 @@ index 2ed4c3c0..cd37a70e 100644 +/usr/sbin/fuse2fs /usr/share/man/man1/fuse2fs.1 diff --git a/misc/Makefile.in b/misc/Makefile.in -index 9f2a8939..216fc771 100644 +index 3e821279..c9e380b6 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in -@@ -35,7 +35,7 @@ INSTALL = @INSTALL@ +@@ -39,7 +39,7 @@ MKDIR_P = @MKDIR_P@ SPROGS= mke2fs badblocks tune2fs dumpe2fs $(BLKID_PROG) logsave \ $(E2IMAGE_PROG) @FSCK_PROG@ e2undo USPROGS= mklost+found filefrag e2freefrag $(UUIDD_PROG) \ @@ -31,7 +33,7 @@ index 9f2a8939..216fc771 100644 SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \ logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \ -@@ -43,7 +43,7 @@ SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ +@@ -47,7 +47,7 @@ SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ e2mmpstatus.8 FMANPAGES= mke2fs.conf.5 ext4.5 @@ -41,5 +43,5 @@ index 9f2a8939..216fc771 100644 UMANPAGES+= @FUSE_CMT@ fuse2fs.1 -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch b/0003-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch similarity index 81% rename from e2fsprogs-1.45.6-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch rename to 0003-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch index a4fe78a0901292dcf752d8d30c87ba4894918704..f9a4a40a55a8f99c77975a983ef90825e97aa14a 100644 --- a/e2fsprogs-1.45.6-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch +++ b/0003-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch @@ -1,9 +1,10 @@ -From 42e4b2148a42ce35d5bc86586341a887928ec4dc Mon Sep 17 00:00:00 2001 +From 36deb51e18d326a723ebf490efd4f8d5fdfef6d5 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Tue, 17 Dec 2019 11:24:31 +0100 -Subject: [PATCH 3/7] mke2fs.conf: Introduce rhel6 and rhel7 fs_type +Subject: [PATCH 03/10] mke2fs.conf: Introduce rhel6 and rhel7 fs_type Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- misc/mke2fs.conf.in | 10 ++++++++++ 1 file changed, 10 insertions(+) @@ -30,5 +31,5 @@ index 01e35cf8..a533b210 100644 blocksize = 1024 inode_size = 128 -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-man-Add-note-about-RHEL8-supported-features-and-moun.patch b/0004-man-Add-note-about-RHEL8-supported-features-and-moun.patch similarity index 92% rename from e2fsprogs-1.45.6-man-Add-note-about-RHEL8-supported-features-and-moun.patch rename to 0004-man-Add-note-about-RHEL8-supported-features-and-moun.patch index f08d1fa414a1231e7d8aa74c2e07983feb0f759b..db74278ef6e42c8e37bb156a55fe1713c4c01c4b 100644 --- a/e2fsprogs-1.45.6-man-Add-note-about-RHEL8-supported-features-and-moun.patch +++ b/0004-man-Add-note-about-RHEL8-supported-features-and-moun.patch @@ -1,17 +1,18 @@ -From b46e1de31f31b9564445a094e1c9cb592062868c Mon Sep 17 00:00:00 2001 +From 6790b5a01d7a992d38d83c955a524cf20cd9aa08 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Wed, 18 Dec 2019 11:03:37 +0100 -Subject: [PATCH 4/7] man: Add note about RHEL8 supported features and mount +Subject: [PATCH 04/10] man: Add note about RHEL8 supported features and mount options Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- misc/ext4.5.in | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ misc/mke2fs.8.in | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/misc/ext4.5.in b/misc/ext4.5.in -index 1db61a5f..39b1412e 100644 +index 90bc4f88..3eb574c0 100644 --- a/misc/ext4.5.in +++ b/misc/ext4.5.in @@ -19,6 +19,54 @@ previously intended for use with the ext2 and ext3 file systems can be @@ -70,7 +71,7 @@ index 1db61a5f..39b1412e 100644 A file system formatted for ext2, ext3, or ext4 can have some collection of the following file system feature flags enabled. Some of diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in -index e6bfc6d6..6106342b 100644 +index 84248ffc..0868d5e8 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -204,6 +204,54 @@ overridden by the options listed below, are controlled by the @@ -129,5 +130,5 @@ index e6bfc6d6..6106342b 100644 .TP .BI \-b " block-size" -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch b/0005-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch similarity index 98% rename from e2fsprogs-1.45.6-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch rename to 0005-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch index b4732486462d3cff0bc8d873132453177b314435..8b1ef7d23c3f67b9aec3525f42af2445c4491764 100644 --- a/e2fsprogs-1.45.6-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch +++ b/0005-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch @@ -1,13 +1,14 @@ -From 1c25e64066e861f273b785b06ef3bc7636552eab Mon Sep 17 00:00:00 2001 +From bdbc1e91195faf63772b8080f38b402d95745bf6 Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Tue, 14 Jan 2020 09:49:19 +0100 -Subject: [PATCH 5/7] Revert "libext2fs: revamp bitmap types to fix LTO +Subject: [PATCH 05/10] Revert "libext2fs: revamp bitmap types to fix LTO warnings" This reverts commit 83d9ffccf3ee6ad4e165eeb6912acf1f6149be28 because it breaks ABI. Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- lib/ext2fs/bitmaps.c | 6 +- lib/ext2fs/blkmap64_ba.c | 38 ++++---- @@ -459,7 +460,7 @@ index de334548..d8c7a3c3 100644 }; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h -index 4b7c836a..ba83534c 100644 +index 6a26abc4..f6cccd0c 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -111,14 +111,9 @@ typedef struct struct_ext2_filsys *ext2_filsys; @@ -862,7 +863,7 @@ index 1536d4b3..b545ed7f 100644 if ((block < bitmap->start) || (block > bitmap->end) || diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c -index 6e4d8b71..47ba2baf 100644 +index b2370667..ee683212 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -68,7 +68,7 @@ @@ -1279,7 +1280,7 @@ index 6e4d8b71..47ba2baf 100644 #ifndef OMIT_COM_ERR if (bitmap && bitmap->description) com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP, -@@ -796,22 +764,21 @@ void ext2fs_warn_bitmap32(ext2fs_generic_bitmap gen_bitmap, const char *func) +@@ -796,45 +764,43 @@ void ext2fs_warn_bitmap32(ext2fs_generic_bitmap gen_bitmap, const char *func) errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, ext2fs_block_bitmap *bitmap) { @@ -1287,8 +1288,7 @@ index 6e4d8b71..47ba2baf 100644 - ext2fs_block_bitmap gen_bmap = *bitmap, gen_cmap; + ext2fs_block_bitmap cmap, bmap; errcode_t retval; - blk64_t i, b_end, c_end; - int n, ratio; + blk64_t i, next, b_end, c_end; - bmap = (ext2fs_generic_bitmap_64) gen_bmap; - if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(gen_bmap)) @@ -1307,18 +1307,17 @@ index 6e4d8b71..47ba2baf 100644 i = bmap->start; b_end = bmap->end; bmap->end = bmap->real_end; -@@ -820,8 +787,8 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, - n = 0; - ratio = 1 << fs->cluster_ratio_bits; + c_end = cmap->end; + cmap->end = cmap->real_end; while (i < bmap->real_end) { -- if (ext2fs_test_block_bitmap2(gen_bmap, i)) { -- ext2fs_mark_block_bitmap2(gen_cmap, i); -+ if (ext2fs_test_block_bitmap2(bmap, i)) { -+ ext2fs_mark_block_bitmap2(cmap, i); - i += ratio - n; - n = 0; - continue; -@@ -832,15 +799,14 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, +- retval = ext2fs_find_first_set_block_bitmap2(gen_bmap, ++ retval = ext2fs_find_first_set_block_bitmap2(bmap, + i, bmap->real_end, &next); + if (retval) + break; +- ext2fs_mark_block_bitmap2(gen_cmap, next); ++ ext2fs_mark_block_bitmap2(cmap, next); + i = EXT2FS_C2B(fs, EXT2FS_B2C(fs, next) + 1); } bmap->end = b_end; cmap->end = c_end; @@ -1336,7 +1335,7 @@ index 6e4d8b71..47ba2baf 100644 __u64 cstart, cend, cout; errcode_t retval; -@@ -866,27 +832,27 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, +@@ -860,27 +826,27 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -1372,7 +1371,7 @@ index 6e4d8b71..47ba2baf 100644 goto found; return ENOENT; -@@ -895,7 +861,6 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, +@@ -889,7 +855,6 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap, errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap, __u64 start, __u64 end, __u64 *out) { @@ -1380,7 +1379,7 @@ index 6e4d8b71..47ba2baf 100644 __u64 cstart, cend, cout; errcode_t retval; -@@ -921,27 +886,27 @@ errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap, +@@ -915,27 +880,27 @@ errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap, if (!EXT2FS_IS_64_BITMAP(bitmap)) return EINVAL; @@ -1417,5 +1416,5 @@ index 6e4d8b71..47ba2baf 100644 return ENOENT; -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch b/0006-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch similarity index 91% rename from e2fsprogs-1.45.6-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch rename to 0006-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch index 17c210d0c7ede2c68a654bec89127873eab8c4d7..7cc11567f97aa000d937c12f3533f47e53a990c5 100644 --- a/e2fsprogs-1.45.6-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch +++ b/0006-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch @@ -1,13 +1,14 @@ -From cdbe6f07c929b0c9a80b7fbeb61b3a9f66015085 Mon Sep 17 00:00:00 2001 +From d2d93a1b057605465857b8f8953dfb54aabacdae Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Tue, 14 Jan 2020 09:49:31 +0100 -Subject: [PATCH 6/7] Revert "libext2fs: hide struct ext2fs_hashmap as an +Subject: [PATCH 06/10] Revert "libext2fs: hide struct ext2fs_hashmap as an internal implementation detail" This reverts commit ef54444e6d1da4b464c11e749c9643ed945a770b because it breaks ABI. Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- lib/ext2fs/hashmap.c | 16 ---------------- lib/ext2fs/hashmap.h | 30 +++++++++++++++++++++--------- @@ -82,5 +83,5 @@ index dcfa7455..656d3d90 100644 struct ext2fs_hashmap *ext2fs_hashmap_create( -- -2.21.3 +2.24.4 diff --git a/e2fsprogs-1.45.6-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch b/0007-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch similarity index 77% rename from e2fsprogs-1.45.6-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch rename to 0007-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch index 82363c594e53b776478ce33d3e80d897394146fa..ab8bf6bcdb672a41a5cdc7a5b6623c9758cdaa9d 100644 --- a/e2fsprogs-1.45.6-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch +++ b/0007-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch @@ -1,7 +1,7 @@ -From 9039cf5c5da439f6c65435c0a2b9ae16989940e1 Mon Sep 17 00:00:00 2001 +From 683f177441d8624c7cfcc3c05a2d6dfe484177ca Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Tue, 14 Jan 2020 20:56:41 +0100 -Subject: [PATCH 7/7] ext2fs: fix ABI change in the struct_ext2_filsys +Subject: [PATCH 07/10] ext2fs: fix ABI change in the struct_ext2_filsys structure Upstream increased size of the struct_ext2_filsys structure by adding @@ -10,15 +10,16 @@ RHEL release. To avoid it use some of the reserved space in the struct_ext2_filsys structure. Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- lib/ext2fs/ext2fs.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h -index ba83534c..32c75171 100644 +index f6cccd0c..e917a7e0 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h -@@ -250,10 +250,17 @@ struct struct_ext2_filsys { +@@ -257,10 +257,17 @@ struct struct_ext2_filsys { int cluster_ratio_bits; __u16 default_bitmap_type; __u16 pad; @@ -37,7 +38,7 @@ index ba83534c..32c75171 100644 /* * Reserved for the use of the calling application. -@@ -304,8 +311,6 @@ struct struct_ext2_filsys { +@@ -311,8 +318,6 @@ struct struct_ext2_filsys { /* hashmap for SHA of data blocks */ struct ext2fs_hashmap* block_sha_map; @@ -47,5 +48,5 @@ index ba83534c..32c75171 100644 #if EXT2_FLAT_INCLUDES -- -2.21.3 +2.24.4 diff --git a/0001-reisze2fs-sanity-check-free-block-group-counts-when-.patch b/0008-reisze2fs-sanity-check-free-block-group-counts-when-.patch similarity index 92% rename from 0001-reisze2fs-sanity-check-free-block-group-counts-when-.patch rename to 0008-reisze2fs-sanity-check-free-block-group-counts-when-.patch index 02266f93eca949d251e95a2afa5972dca3d9eb1e..d4c6671011e8a6dcb56a667499e91fda99f418de 100644 --- a/0001-reisze2fs-sanity-check-free-block-group-counts-when-.patch +++ b/0008-reisze2fs-sanity-check-free-block-group-counts-when-.patch @@ -1,7 +1,7 @@ -From 2c98da4e6a3e106c340972adedc6f79c4c1969f2 Mon Sep 17 00:00:00 2001 +From 974cce63bb877c99823376dca72d1cc0edb13a96 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 28 Dec 2021 12:33:15 -0500 -Subject: [PATCH] reisze2fs: sanity check free block group counts when +Subject: [PATCH 08/10] reisze2fs: sanity check free block group counts when calculating minimum size If one or more block group descriptor's free blocks count is insane, @@ -19,6 +19,7 @@ https://github.com/tytso/e2fsprogs/issues/94 Fixes: ac94445fc01f ("resize2fs: make minimum size estimates more reliable for mounted fs") Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi --- resize/resize2fs.c | 13 +++++++++-- tests/r_corrupt_fs/expect | 4 ++++ @@ -30,10 +31,10 @@ Signed-off-by: Theodore Ts'o create mode 100644 tests/r_corrupt_fs/script diff --git a/resize/resize2fs.c b/resize/resize2fs.c -index 8a3d08db..26050fec 100644 +index 270e4deb..8631f8c9 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c -@@ -2928,8 +2928,17 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) +@@ -2929,8 +2929,17 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) /* calculate how many blocks are needed for data */ data_needed = ext2fs_blocks_count(fs->super); for (grp = 0; grp < fs->group_desc_count; grp++) { @@ -122,5 +123,5 @@ index 00000000..08af91ed + +unset IMAGE OUT EXP TIMEOUT -- -2.34.1 +2.24.4 diff --git a/0001-tests-support-older-versions-of-timeout-in-r_corrupt.patch b/0009-tests-support-older-versions-of-timeout-in-r_corrupt.patch similarity index 82% rename from 0001-tests-support-older-versions-of-timeout-in-r_corrupt.patch rename to 0009-tests-support-older-versions-of-timeout-in-r_corrupt.patch index 884299e50a9bf68f31832793ef65b1b5ccad6a44..c885bd482bff67e116f574117b141a302a2c12ed 100644 --- a/0001-tests-support-older-versions-of-timeout-in-r_corrupt.patch +++ b/0009-tests-support-older-versions-of-timeout-in-r_corrupt.patch @@ -1,7 +1,8 @@ -From af09db229f74f447aec12e440252d8a94c049f26 Mon Sep 17 00:00:00 2001 +From 7f90a0b6ea3d5f717556c266bc2493cbe5bcc17c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 3 Jan 2022 22:45:37 -0500 -Subject: [PATCH] tests: support older versions of timeout in r_corrupt_fs +Subject: [PATCH 09/10] tests: support older versions of timeout in + r_corrupt_fs Older versions of the timeout program in coreutils don't support the -v option. (This is apparently still in use in the GNU/FreeBSD Debain @@ -9,6 +10,7 @@ port since coreutils hasn't built successfully since Coreutils version 8.28.) Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi --- tests/r_corrupt_fs/script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) @@ -27,5 +29,5 @@ index 08af91ed..f6d3a89d 100644 else TIMEOUT= -- -2.34.1 +2.24.4 diff --git a/0001-tests-specify-inode-size-in-r_corrupt_fs.patch b/0010-tests-specify-inode-size-in-r_corrupt_fs.patch similarity index 89% rename from 0001-tests-specify-inode-size-in-r_corrupt_fs.patch rename to 0010-tests-specify-inode-size-in-r_corrupt_fs.patch index 477e45f80d8b7887bf0d4ea60ec51b9f27fff1a9..2387128b361f8d42ae9f59ee32dd1f414be7c097 100644 --- a/0001-tests-specify-inode-size-in-r_corrupt_fs.patch +++ b/0010-tests-specify-inode-size-in-r_corrupt_fs.patch @@ -1,13 +1,14 @@ -From 0ec67ba5063b1fdcad4142633338c2cc98b60b5b Mon Sep 17 00:00:00 2001 +From cd1e297c041af2b32a55e2a2ec56b0fa792e62fd Mon Sep 17 00:00:00 2001 From: Lukas Czerner Date: Wed, 16 Feb 2022 11:12:28 +0100 -Subject: [PATCH] tests: specify inode size in r_corrupt_fs +Subject: [PATCH 10/10] tests: specify inode size in r_corrupt_fs Inode size will have an effect on the minimum resize size and this will have an effect on the test output. Stabilize the output by specifying the inode size instead of relying on the system configuration. Signed-off-by: Lukas Czerner +Signed-off-by: Joseph Qi --- tests/r_corrupt_fs/expect | 2 +- tests/r_corrupt_fs/script | 4 ++-- @@ -39,5 +40,5 @@ index f6d3a89d..45bbe071 100644 echo debugfs -w -R \"set_bg 1 free_blocks_count 65536\" /tmp/foo.img >> $OUT.new $DEBUGFS -w -R "set_bg 1 free_blocks_count 65536" $TMPFILE > /dev/null 2>&1 -- -2.34.1 +2.24.4 diff --git a/1001-Disable-metadata_csum-for-ext4-by-default-until-upst.patch b/1001-Disable-metadata_csum-for-ext4-by-default-until-upst.patch new file mode 100644 index 0000000000000000000000000000000000000000..a722070d2ce8ca415b738fb0e77dc2e58792d1b4 --- /dev/null +++ b/1001-Disable-metadata_csum-for-ext4-by-default-until-upst.patch @@ -0,0 +1,36 @@ +From 9a176b97faadaabca497f54adc32ba6656c33605 Mon Sep 17 00:00:00 2001 +From: Joseph Qi +Date: Fri, 12 Aug 2022 11:23:37 +0800 +Subject: [PATCH 1/9] Disable metadata_csum for ext4 by default until upstream + fix perf loss + +AIM9 benchmarks show there are 17%~62% system perf regression loss if +ext4 metadata_csum enabled. Here we disable this default metadata_csum +for ext4 until upstream fix perf regression loss. + +Signed-off-by: Jacob Wang +(cherry picked from commit 7964b9c2e16fe478bc6560b783e9fa9f6fcf3661) +[ caspar: adjust patch to apply in new version ] +Signed-off-by: Caspar Zhang +Signed-off-by: weitao zhou +Signed-off-by: Joseph Qi +--- + misc/mke2fs.conf.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/mke2fs.conf.in b/misc/mke2fs.conf.in +index a533b210..99a29fdb 100644 +--- a/misc/mke2fs.conf.in ++++ b/misc/mke2fs.conf.in +@@ -11,7 +11,7 @@ + features = has_journal + } + ext4 = { +- features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize ++ features = has_journal,extent,huge_file,flex_bg,uninit_bg,64bit,dir_nlink,extra_isize + inode_size = 256 + } + rhel6_ext4 = { +-- +2.24.4 + diff --git a/1001-e2fsprogs-1.44.6-disable-metadata_csum-by-default.patch b/1001-e2fsprogs-1.44.6-disable-metadata_csum-by-default.patch deleted file mode 100644 index b1aeb557d5f344d497f850b7c757fbab990161a4..0000000000000000000000000000000000000000 --- a/1001-e2fsprogs-1.44.6-disable-metadata_csum-by-default.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nuar e2fsprogs-1.44.6.orig/misc/mke2fs.conf.in e2fsprogs-1.44.6/misc/mke2fs.conf.in ---- e2fsprogs-1.44.6.orig/misc/mke2fs.conf.in 2019-03-06 04:11:11.000000000 +0800 -+++ e2fsprogs-1.44.6/misc/mke2fs.conf.in 2020-08-27 15:35:20.508576799 +0800 -@@ -11,7 +11,7 @@ - features = has_journal - } - ext4 = { -- features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize -+ features = has_journal,extent,huge_file,flex_bg,uninit_bg,64bit,dir_nlink,extra_isize - inode_size = 256 - } - rhel6_ext4 = { diff --git a/1002-e2fsck-endianness-fixes-for-fast-commit-replay.patch b/1002-e2fsck-endianness-fixes-for-fast-commit-replay.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b9a2be391725423d60b0862fa535117d867e0e0 --- /dev/null +++ b/1002-e2fsck-endianness-fixes-for-fast-commit-replay.patch @@ -0,0 +1,122 @@ +From ea26a4be8bee31032167b18c2b0e55a295f58952 Mon Sep 17 00:00:00 2001 +From: Harshad Shirwadkar +Date: Thu, 4 Feb 2021 15:36:01 -0800 +Subject: [PATCH 2/9] e2fsck: endianness fixes for fast commit replay + +There are a few places where the endianness conversion wasn't done +right. This patch fixes that. Verified that after this patch, +j_recover_fast_commit passes on big endian qemu VM. + +root@debian-powerpc:~/e2fsprogs/tests# make j_recover_fast_commit +j_recover_fast_commit: : ok + +Signed-off-by: Harshad Shirwadkar +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/journal.c | 44 ++++++++++++++++++++++++++------------------ + 1 file changed, 26 insertions(+), 18 deletions(-) + +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index 922c252d..2708942a 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -706,19 +706,19 @@ out: + static void ext4_fc_replay_fixup_iblocks(struct ext2_inode_large *ondisk_inode, + struct ext2_inode_large *fc_inode) + { +- if (le32_to_cpu(ondisk_inode->i_flags) & EXT4_EXTENTS_FL) { ++ if (ondisk_inode->i_flags & EXT4_EXTENTS_FL) { + struct ext3_extent_header *eh; + + eh = (struct ext3_extent_header *)(&ondisk_inode->i_block[0]); +- if (eh->eh_magic != EXT3_EXT_MAGIC) { ++ if (le16_to_cpu(eh->eh_magic) != EXT3_EXT_MAGIC) { + memset(eh, 0, sizeof(*eh)); +- eh->eh_magic = EXT3_EXT_MAGIC; ++ eh->eh_magic = cpu_to_le16(EXT3_EXT_MAGIC); + eh->eh_max = cpu_to_le16( + (sizeof(ondisk_inode->i_block) - + sizeof(struct ext3_extent_header)) / +- sizeof(struct ext3_extent)); ++ sizeof(struct ext3_extent)); + } +- } else if (le32_to_cpu(ondisk_inode->i_flags) & EXT4_INLINE_DATA_FL) { ++ } else if (ondisk_inode->i_flags & EXT4_INLINE_DATA_FL) { + memcpy(ondisk_inode->i_block, fc_inode->i_block, + sizeof(fc_inode->i_block)); + } +@@ -728,34 +728,41 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) + { + struct e2fsck_fc_replay_state *state = &ctx->fc_replay_state; + int ino, inode_len = EXT2_GOOD_OLD_INODE_SIZE; +- struct ext2_inode_large *inode = NULL; +- struct ext4_fc_inode *fc_inode; ++ struct ext2_inode_large *inode = NULL, *fc_inode = NULL; ++ struct ext4_fc_inode *fc_inode_val; + errcode_t err; + blk64_t blks; + +- fc_inode = (struct ext4_fc_inode *)ext4_fc_tag_val(tl); +- ino = le32_to_cpu(fc_inode->fc_ino); ++ fc_inode_val = (struct ext4_fc_inode *)ext4_fc_tag_val(tl); ++ ino = le32_to_cpu(fc_inode_val->fc_ino); + + if (EXT2_INODE_SIZE(ctx->fs->super) > EXT2_GOOD_OLD_INODE_SIZE) + inode_len += ext2fs_le16_to_cpu( +- ((struct ext2_inode_large *)fc_inode->fc_raw_inode) ++ ((struct ext2_inode_large *)fc_inode_val->fc_raw_inode) + ->i_extra_isize); + err = ext2fs_get_mem(inode_len, &inode); + if (err) +- return errcode_to_errno(err); ++ goto out; ++ err = ext2fs_get_mem(inode_len, &fc_inode); ++ if (err) ++ goto out; + ext4_fc_flush_extents(ctx, ino); + + err = ext2fs_read_inode_full(ctx->fs, ino, (struct ext2_inode *)inode, + inode_len); + if (err) + goto out; +- memcpy(inode, fc_inode->fc_raw_inode, +- offsetof(struct ext2_inode_large, i_block)); +- memcpy(&inode->i_generation, +- &((struct ext2_inode_large *)(fc_inode->fc_raw_inode))->i_generation, ++#ifdef WORDS_BIGENDIAN ++ ext2fs_swap_inode_full(ctx->fs, fc_inode, ++ (struct ext2_inode_large *)fc_inode_val->fc_raw_inode, ++ 0, sizeof(*inode)); ++#else ++ memcpy(fc_inode, fc_inode_val->fc_raw_inode, inode_len); ++#endif ++ memcpy(inode, fc_inode, offsetof(struct ext2_inode_large, i_block)); ++ memcpy(&inode->i_generation, &fc_inode->i_generation, + inode_len - offsetof(struct ext2_inode_large, i_generation)); +- ext4_fc_replay_fixup_iblocks(inode, +- (struct ext2_inode_large *)fc_inode->fc_raw_inode); ++ ext4_fc_replay_fixup_iblocks(inode, fc_inode); + err = ext2fs_count_blocks(ctx->fs, ino, EXT2_INODE(inode), &blks); + if (err) + goto out; +@@ -774,6 +781,7 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) + + out: + ext2fs_free_mem(&inode); ++ ext2fs_free_mem(&fc_inode); + return errcode_to_errno(err); + } + +@@ -819,7 +827,7 @@ static int ext4_fc_handle_del_range(e2fsck_t ctx, struct ext4_fc_tl *tl) + + memset(&extent, 0, sizeof(extent)); + extent.e_lblk = ext2fs_le32_to_cpu(del_range->fc_lblk); +- extent.e_len = ext2fs_le16_to_cpu(del_range->fc_len); ++ extent.e_len = ext2fs_le32_to_cpu(del_range->fc_len); + ret = ext4_fc_read_extents(ctx, ino); + if (ret) + return ret; +-- +2.24.4 + diff --git a/1003-e2fsck-add-fallthrough-comment-in-fc-replay-switch-c.patch b/1003-e2fsck-add-fallthrough-comment-in-fc-replay-switch-c.patch new file mode 100644 index 0000000000000000000000000000000000000000..8eb5b6acf11e9d2d4f395b3bb630ebfa2991c1d7 --- /dev/null +++ b/1003-e2fsck-add-fallthrough-comment-in-fc-replay-switch-c.patch @@ -0,0 +1,31 @@ +From d8aa67a8799f42eee0edc4c979e8e88e27a9aedb Mon Sep 17 00:00:00 2001 +From: Harshad Shirwadkar +Date: Tue, 23 Feb 2021 09:41:55 -0800 +Subject: [PATCH 3/9] e2fsck: add fallthrough comment in fc replay switch case + +During fast commit replay scan phase, in ext4_fc_replay_scan(), we +want to fallthrough in switch case for EXT4_FC_TAG_ADD_RANGE case. Add +a comment for that. + +Signed-off-by: Harshad Shirwadkar +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/journal.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index 2708942a..a67ef745 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -325,6 +325,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + ret = JBD2_FC_REPLAY_STOP; + else + ret = JBD2_FC_REPLAY_CONTINUE; ++ /* fallthrough */ + case EXT4_FC_TAG_DEL_RANGE: + case EXT4_FC_TAG_LINK: + case EXT4_FC_TAG_UNLINK: +-- +2.24.4 + diff --git a/1004-e2fsck-initialize-variable-before-first-use-in-fast-.patch b/1004-e2fsck-initialize-variable-before-first-use-in-fast-.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf8df1003a7dbf8489e4da43b2d891a73d414a4e --- /dev/null +++ b/1004-e2fsck-initialize-variable-before-first-use-in-fast-.patch @@ -0,0 +1,48 @@ +From 780f047c749a582806326d75180fe68d84e220c2 Mon Sep 17 00:00:00 2001 +From: Harshad Shirwadkar +Date: Tue, 23 Feb 2021 09:41:56 -0800 +Subject: [PATCH 4/9] e2fsck: initialize variable before first use in fast + commit replay + +Initialize ext2fs_ex variable in ext4_fc_replay_scan() before first +use. Also make sure ext2fs_decode_extent() completely overwrites the +extent structure passed to it as argument to prevent potential future +bugs for the users of the function. + +Signed-off-by: Harshad Shirwadkar +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/journal.c | 2 +- + lib/ext2fs/extent.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index a67ef745..8e7ba819 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -289,7 +289,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + struct ext4_fc_tail *tail; + __u8 *start, *end; + struct ext4_fc_head *head; +- struct ext2fs_extent ext2fs_ex; ++ struct ext2fs_extent ext2fs_ex = {0}; + + state = &ctx->fc_replay_state; + +diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c +index bde6b0f3..542e5034 100644 +--- a/lib/ext2fs/extent.c ++++ b/lib/ext2fs/extent.c +@@ -1797,7 +1797,7 @@ errcode_t ext2fs_decode_extent(struct ext2fs_extent *to, void *addr, int len) + << 32); + to->e_lblk = ext2fs_le32_to_cpu(from->ee_block); + to->e_len = ext2fs_le16_to_cpu(from->ee_len); +- to->e_flags |= EXT2_EXTENT_FLAGS_LEAF; ++ to->e_flags = EXT2_EXTENT_FLAGS_LEAF; + if (to->e_len > EXT_INIT_MAX_LEN) { + to->e_len -= EXT_INIT_MAX_LEN; + to->e_flags |= EXT2_EXTENT_FLAGS_UNINIT; +-- +2.24.4 + diff --git a/1005-e2fsck-fix-portability-problems-caused-by-unaligned-.patch b/1005-e2fsck-fix-portability-problems-caused-by-unaligned-.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b40c47b4d185c0ef8ed59ab1d672a10e9377e9f --- /dev/null +++ b/1005-e2fsck-fix-portability-problems-caused-by-unaligned-.patch @@ -0,0 +1,327 @@ +From 39b05f968b38180c3a2e0159c75e1a4afed2c691 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Mon, 3 May 2021 15:37:33 -0400 +Subject: [PATCH 5/9] e2fsck: fix portability problems caused by unaligned + accesses + +The on-disk format for the ext4 journal can have unaigned 32-bit +integers. This can happen when replaying a journal using a obsolete +checksum format (which was never popularly used, since the v3 format +replaced v2 while the metadata checksum feature was being stablized), +and in the fast commit feature (which landed in the 5.10 kernel, +although it is not enabled by default). + +This commit fixes the following regression tests on some platforms +(such as running 32-bit arm architectures on a 64-bit arm kernel): +j_recover_csum2_32bit, j_recover_csum2_64bit, j_recover_fast_commit. + +https://github.com/tytso/e2fsprogs/issues/65 + +Addresses-Debian-Bug: #987641 +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/journal.c | 83 ++++++++++++++++-------------- + e2fsck/recovery.c | 22 ++++---- + tests/j_recover_fast_commit/script | 1 - + 3 files changed, 56 insertions(+), 50 deletions(-) + +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index 8e7ba819..bd0e4f31 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -286,9 +286,9 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + int ret = JBD2_FC_REPLAY_CONTINUE; + struct ext4_fc_add_range *ext; + struct ext4_fc_tl *tl; +- struct ext4_fc_tail *tail; ++ struct ext4_fc_tail tail; + __u8 *start, *end; +- struct ext4_fc_head *head; ++ struct ext4_fc_head head; + struct ext2fs_extent ext2fs_ex = {0}; + + state = &ctx->fc_replay_state; +@@ -338,16 +338,15 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + break; + case EXT4_FC_TAG_TAIL: + state->fc_cur_tag++; +- tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); ++ memcpy(&tail, ext4_fc_tag_val(tl), sizeof(tail)); + state->fc_crc = jbd2_chksum(j, state->fc_crc, tl, + sizeof(*tl) + + offsetof(struct ext4_fc_tail, + fc_crc)); + jbd_debug(1, "tail tid %d, expected %d\n", +- le32_to_cpu(tail->fc_tid), +- expected_tid); +- if (le32_to_cpu(tail->fc_tid) == expected_tid && +- le32_to_cpu(tail->fc_crc) == state->fc_crc) { ++ le32_to_cpu(tail.fc_tid), expected_tid); ++ if (le32_to_cpu(tail.fc_tid) == expected_tid && ++ le32_to_cpu(tail.fc_crc) == state->fc_crc) { + state->fc_replay_num_tags = state->fc_cur_tag; + } else { + ret = state->fc_replay_num_tags ? +@@ -356,13 +355,13 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + state->fc_crc = 0; + break; + case EXT4_FC_TAG_HEAD: +- head = (struct ext4_fc_head *)ext4_fc_tag_val(tl); +- if (le32_to_cpu(head->fc_features) & +- ~EXT4_FC_SUPPORTED_FEATURES) { ++ memcpy(&head, ext4_fc_tag_val(tl), sizeof(head)); ++ if (le32_to_cpu(head.fc_features) & ++ ~EXT4_FC_SUPPORTED_FEATURES) { + ret = -EOPNOTSUPP; + break; + } +- if (le32_to_cpu(head->fc_tid) != expected_tid) { ++ if (le32_to_cpu(head.fc_tid) != expected_tid) { + ret = -EINVAL; + break; + } +@@ -612,27 +611,31 @@ struct dentry_info_args { + char *dname; + }; + +-static inline void tl_to_darg(struct dentry_info_args *darg, ++static inline int tl_to_darg(struct dentry_info_args *darg, + struct ext4_fc_tl *tl) + { +- struct ext4_fc_dentry_info *fcd; ++ struct ext4_fc_dentry_info fcd; + int tag = le16_to_cpu(tl->fc_tag); + +- fcd = (struct ext4_fc_dentry_info *)ext4_fc_tag_val(tl); ++ memcpy(&fcd, ext4_fc_tag_val(tl), sizeof(fcd)); + +- darg->parent_ino = le32_to_cpu(fcd->fc_parent_ino); +- darg->ino = le32_to_cpu(fcd->fc_ino); +- darg->dname = fcd->fc_dname; ++ darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); ++ darg->ino = le32_to_cpu(fcd.fc_ino); + darg->dname_len = ext4_fc_tag_len(tl) - + sizeof(struct ext4_fc_dentry_info); + darg->dname = malloc(darg->dname_len + 1); +- memcpy(darg->dname, fcd->fc_dname, darg->dname_len); ++ if (!darg->dname) ++ return -ENOMEM; ++ memcpy(darg->dname, ++ ext4_fc_tag_val(tl) + sizeof(struct ext4_fc_dentry_info), ++ darg->dname_len); + darg->dname[darg->dname_len] = 0; + jbd_debug(1, "%s: %s, ino %d, parent %d\n", + tag == EXT4_FC_TAG_CREAT ? "create" : + (tag == EXT4_FC_TAG_LINK ? "link" : + (tag == EXT4_FC_TAG_UNLINK ? "unlink" : "error")), + darg->dname, darg->ino, darg->parent_ino); ++ return 0; + } + + static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl) +@@ -642,7 +645,9 @@ static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl) + ext2_filsys fs = ctx->fs; + int ret; + +- tl_to_darg(&darg, tl); ++ ret = tl_to_darg(&darg, tl); ++ if (ret) ++ return ret; + ext4_fc_flush_extents(ctx, darg.ino); + ret = errcode_to_errno( + ext2fs_unlink(ctx->fs, darg.parent_ino, +@@ -659,7 +664,9 @@ static int ext4_fc_handle_link_and_create(e2fsck_t ctx, struct ext4_fc_tl *tl) + struct ext2_inode_large inode_large; + int ret, filetype, mode; + +- tl_to_darg(&darg, tl); ++ ret = tl_to_darg(&darg, tl); ++ if (ret) ++ return ret; + ext4_fc_flush_extents(ctx, 0); + ret = errcode_to_errno(ext2fs_read_inode(fs, darg.ino, + (struct ext2_inode *)&inode_large)); +@@ -730,17 +737,18 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) + struct e2fsck_fc_replay_state *state = &ctx->fc_replay_state; + int ino, inode_len = EXT2_GOOD_OLD_INODE_SIZE; + struct ext2_inode_large *inode = NULL, *fc_inode = NULL; +- struct ext4_fc_inode *fc_inode_val; ++ __le32 fc_ino; ++ __u8 *fc_raw_inode; + errcode_t err; + blk64_t blks; + +- fc_inode_val = (struct ext4_fc_inode *)ext4_fc_tag_val(tl); +- ino = le32_to_cpu(fc_inode_val->fc_ino); ++ memcpy(&fc_ino, ext4_fc_tag_val(tl), sizeof(fc_ino)); ++ fc_raw_inode = ext4_fc_tag_val(tl) + sizeof(fc_ino); ++ ino = le32_to_cpu(fc_ino); + + if (EXT2_INODE_SIZE(ctx->fs->super) > EXT2_GOOD_OLD_INODE_SIZE) + inode_len += ext2fs_le16_to_cpu( +- ((struct ext2_inode_large *)fc_inode_val->fc_raw_inode) +- ->i_extra_isize); ++ ((struct ext2_inode_large *)fc_raw_inode)->i_extra_isize); + err = ext2fs_get_mem(inode_len, &inode); + if (err) + goto out; +@@ -755,10 +763,10 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) + goto out; + #ifdef WORDS_BIGENDIAN + ext2fs_swap_inode_full(ctx->fs, fc_inode, +- (struct ext2_inode_large *)fc_inode_val->fc_raw_inode, ++ (struct ext2_inode_large *)fc_raw_inode, + 0, sizeof(*inode)); + #else +- memcpy(fc_inode, fc_inode_val->fc_raw_inode, inode_len); ++ memcpy(fc_inode, fc_raw_inode, inode_len); + #endif + memcpy(inode, fc_inode, offsetof(struct ext2_inode_large, i_block)); + memcpy(&inode->i_generation, &fc_inode->i_generation, +@@ -792,12 +800,11 @@ out: + static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) + { + struct ext2fs_extent extent; +- struct ext4_fc_add_range *add_range; +- struct ext4_fc_del_range *del_range; ++ struct ext4_fc_add_range add_range; + int ret = 0, ino; + +- add_range = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); +- ino = le32_to_cpu(add_range->fc_ino); ++ memcpy(&add_range, ext4_fc_tag_val(tl), sizeof(add_range)); ++ ino = le32_to_cpu(add_range.fc_ino); + ext4_fc_flush_extents(ctx, ino); + + ret = ext4_fc_read_extents(ctx, ino); +@@ -805,8 +812,8 @@ static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) + return ret; + memset(&extent, 0, sizeof(extent)); + ret = errcode_to_errno(ext2fs_decode_extent( +- &extent, (void *)(add_range->fc_ex), +- sizeof(add_range->fc_ex))); ++ &extent, (void *)add_range.fc_ex, ++ sizeof(add_range.fc_ex))); + if (ret) + return ret; + return ext4_add_extent_to_list(ctx, +@@ -819,16 +826,16 @@ static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) + static int ext4_fc_handle_del_range(e2fsck_t ctx, struct ext4_fc_tl *tl) + { + struct ext2fs_extent extent; +- struct ext4_fc_del_range *del_range; ++ struct ext4_fc_del_range del_range; + int ret, ino; + +- del_range = (struct ext4_fc_del_range *)ext4_fc_tag_val(tl); +- ino = le32_to_cpu(del_range->fc_ino); ++ memcpy(&del_range, ext4_fc_tag_val(tl), sizeof(del_range)); ++ ino = le32_to_cpu(del_range.fc_ino); + ext4_fc_flush_extents(ctx, ino); + + memset(&extent, 0, sizeof(extent)); +- extent.e_lblk = ext2fs_le32_to_cpu(del_range->fc_lblk); +- extent.e_len = ext2fs_le32_to_cpu(del_range->fc_len); ++ extent.e_lblk = le32_to_cpu(del_range.fc_lblk); ++ extent.e_len = le32_to_cpu(del_range.fc_len); + ret = ext4_fc_read_extents(ctx, ino); + if (ret) + return ret; +diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c +index dc0694fc..02694d2c 100644 +--- a/e2fsck/recovery.c ++++ b/e2fsck/recovery.c +@@ -196,7 +196,7 @@ static int jbd2_descriptor_block_csum_verify(journal_t *j, void *buf) + static int count_tags(journal_t *journal, struct buffer_head *bh) + { + char * tagp; +- journal_block_tag_t * tag; ++ journal_block_tag_t tag; + int nr = 0, size = journal->j_blocksize; + int tag_bytes = journal_tag_bytes(journal); + +@@ -206,14 +206,14 @@ static int count_tags(journal_t *journal, struct buffer_head *bh) + tagp = &bh->b_data[sizeof(journal_header_t)]; + + while ((tagp - bh->b_data + tag_bytes) <= size) { +- tag = (journal_block_tag_t *) tagp; ++ memcpy(&tag, tagp, sizeof(tag)); + + nr++; + tagp += tag_bytes; +- if (!(tag->t_flags & cpu_to_be16(JBD2_FLAG_SAME_UUID))) ++ if (!(tag.t_flags & cpu_to_be16(JBD2_FLAG_SAME_UUID))) + tagp += 16; + +- if (tag->t_flags & cpu_to_be16(JBD2_FLAG_LAST_TAG)) ++ if (tag.t_flags & cpu_to_be16(JBD2_FLAG_LAST_TAG)) + break; + } + +@@ -434,9 +434,9 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf) + } + + static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, ++ journal_block_tag3_t *tag3, + void *buf, __u32 sequence) + { +- journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag; + __u32 csum32; + __be32 seq; + +@@ -497,7 +497,7 @@ static int do_one_pass(journal_t *journal, + while (1) { + int flags; + char * tagp; +- journal_block_tag_t * tag; ++ journal_block_tag_t tag; + struct buffer_head * obh; + struct buffer_head * nbh; + +@@ -614,8 +614,8 @@ static int do_one_pass(journal_t *journal, + <= journal->j_blocksize - descr_csum_size) { + unsigned long io_block; + +- tag = (journal_block_tag_t *) tagp; +- flags = be16_to_cpu(tag->t_flags); ++ memcpy(&tag, tagp, sizeof(tag)); ++ flags = be16_to_cpu(tag.t_flags); + + io_block = next_log_block++; + wrap(journal, next_log_block); +@@ -633,7 +633,7 @@ static int do_one_pass(journal_t *journal, + + J_ASSERT(obh != NULL); + blocknr = read_tag_block(journal, +- tag); ++ &tag); + + /* If the block has been + * revoked, then we're all done +@@ -648,8 +648,8 @@ static int do_one_pass(journal_t *journal, + + /* Look for block corruption */ + if (!jbd2_block_tag_csum_verify( +- journal, tag, obh->b_data, +- be32_to_cpu(tmp->h_sequence))) { ++ journal, &tag, (journal_block_tag3_t *)tagp, ++ obh->b_data, be32_to_cpu(tmp->h_sequence))) { + brelse(obh); + success = -EFSBADCRC; + printk(KERN_ERR "JBD2: Invalid " +diff --git a/tests/j_recover_fast_commit/script b/tests/j_recover_fast_commit/script +index 22ef6325..05c40cc5 100755 +--- a/tests/j_recover_fast_commit/script ++++ b/tests/j_recover_fast_commit/script +@@ -10,7 +10,6 @@ gunzip < $IMAGE > $TMPFILE + EXP=$test_dir/expect + OUT=$test_name.log + +-cp $TMPFILE /tmp/debugthis + $FSCK $FSCK_OPT -E journal_only -N test_filesys $TMPFILE 2>/dev/null | head -n 1000 | tail -n +2 > $OUT + echo "Exit status is $?" >> $OUT + +-- +2.24.4 + diff --git a/1006-e2fsck-fix-unaligned-accesses-to-ext4_fc_tl-struct.patch b/1006-e2fsck-fix-unaligned-accesses-to-ext4_fc_tl-struct.patch new file mode 100644 index 0000000000000000000000000000000000000000..a53dccf047b62108f4e1a50cc959c7a47110b171 --- /dev/null +++ b/1006-e2fsck-fix-unaligned-accesses-to-ext4_fc_tl-struct.patch @@ -0,0 +1,390 @@ +From db72939f489a02d2148f8d1f50181a646ff810e4 Mon Sep 17 00:00:00 2001 +From: Harshad Shirwadkar +Date: Thu, 6 May 2021 17:21:10 -0700 +Subject: [PATCH 6/9] e2fsck: fix unaligned accesses to ext4_fc_tl struct + +Fast commit related struct ext4_fc_tl can be unaligned on disk. So, +while accessing that we should ensure that the pointers are +aligned. This patch fixes unaligned accesses to ext4_fc_tl and also +gets rid of macros fc_for_each_tl and ext4_fc_tag_val that may result +in unaligned accesses to struct ext4_fc_tl. + +Signed-off-by: Harshad Shirwadkar +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + debugfs/logdump.c | 42 ++++++++++---------- + e2fsck/journal.c | 82 +++++++++++++++++++++------------------- + lib/ext2fs/fast_commit.h | 13 ------- + 3 files changed, 65 insertions(+), 72 deletions(-) + +diff --git a/debugfs/logdump.c b/debugfs/logdump.c +index a94043f3..22fee4d7 100644 +--- a/debugfs/logdump.c ++++ b/debugfs/logdump.c +@@ -520,24 +520,28 @@ static inline size_t journal_super_tag_bytes(journal_superblock_t *jsb) + static void dump_fc_block(FILE *out_file, char *buf, int blocksize, + int transaction, int *fc_done, int dump_old) + { +- struct ext4_fc_tl *tl; ++ struct ext4_fc_tl tl; + struct ext4_fc_head *head; + struct ext4_fc_add_range *add_range; + struct ext4_fc_del_range *del_range; + struct ext4_fc_dentry_info *dentry_info; + struct ext4_fc_tail *tail; + struct ext3_extent *ex; ++ __u8 *cur, *val; + + *fc_done = 0; +- fc_for_each_tl(buf, buf + blocksize, tl) { +- switch (le16_to_cpu(tl->fc_tag)) { ++ for (cur = (__u8 *)buf; cur < (__u8 *)buf + blocksize; ++ cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) { ++ memcpy(&tl, cur, sizeof(tl)); ++ val = cur + sizeof(tl); ++ ++ switch (le16_to_cpu(tl.fc_tag)) { + case EXT4_FC_TAG_ADD_RANGE: +- add_range = +- (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); ++ add_range = (struct ext4_fc_add_range *)val; + ex = (struct ext3_extent *)add_range->fc_ex; + fprintf(out_file, + "tag %s, inode %d, lblk %lu, pblk %llu, len %lu\n", +- tag2str(tl->fc_tag), ++ tag2str(tl.fc_tag), + le32_to_cpu(add_range->fc_ino), + le32_to_cpu(ex->ee_block), + le32_to_cpu(ex->ee_start) + +@@ -547,10 +551,9 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize, + le16_to_cpu(ex->ee_len)); + break; + case EXT4_FC_TAG_DEL_RANGE: +- del_range = +- (struct ext4_fc_del_range *)ext4_fc_tag_val(tl); ++ del_range = (struct ext4_fc_del_range *)val; + fprintf(out_file, "tag %s, inode %d, lblk %d, len %d\n", +- tag2str(tl->fc_tag), ++ tag2str(tl.fc_tag), + le32_to_cpu(del_range->fc_ino), + le32_to_cpu(del_range->fc_lblk), + le32_to_cpu(del_range->fc_len)); +@@ -558,29 +561,26 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize, + case EXT4_FC_TAG_LINK: + case EXT4_FC_TAG_UNLINK: + case EXT4_FC_TAG_CREAT: +- dentry_info = +- (struct ext4_fc_dentry_info *) +- ext4_fc_tag_val(tl); ++ dentry_info = (struct ext4_fc_dentry_info *)val; + fprintf(out_file, + "tag %s, parent %d, ino %d, name \"%s\"\n", +- tag2str(tl->fc_tag), ++ tag2str(tl.fc_tag), + le32_to_cpu(dentry_info->fc_parent_ino), + le32_to_cpu(dentry_info->fc_ino), + dentry_info->fc_dname); + break; + case EXT4_FC_TAG_INODE: + fprintf(out_file, "tag %s, inode %d\n", +- tag2str(tl->fc_tag), +- le32_to_cpu(((struct ext4_fc_inode *) +- ext4_fc_tag_val(tl))->fc_ino)); ++ tag2str(tl.fc_tag), ++ le32_to_cpu(((struct ext4_fc_inode *)val)->fc_ino)); + break; + case EXT4_FC_TAG_PAD: +- fprintf(out_file, "tag %s\n", tag2str(tl->fc_tag)); ++ fprintf(out_file, "tag %s\n", tag2str(tl.fc_tag)); + break; + case EXT4_FC_TAG_TAIL: +- tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); ++ tail = (struct ext4_fc_tail *)val; + fprintf(out_file, "tag %s, tid %d\n", +- tag2str(tl->fc_tag), ++ tag2str(tl.fc_tag), + le32_to_cpu(tail->fc_tid)); + if (!dump_old && + le32_to_cpu(tail->fc_tid) < transaction) { +@@ -590,9 +590,9 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize, + break; + case EXT4_FC_TAG_HEAD: + fprintf(out_file, "\n*** Fast Commit Area ***\n"); +- head = (struct ext4_fc_head *)ext4_fc_tag_val(tl); ++ head = (struct ext4_fc_head *)val; + fprintf(out_file, "tag %s, features 0x%x, tid %d\n", +- tag2str(tl->fc_tag), ++ tag2str(tl.fc_tag), + le32_to_cpu(head->fc_features), + le32_to_cpu(head->fc_tid)); + if (!dump_old && +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index bd0e4f31..ae3df800 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -285,9 +285,9 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + struct e2fsck_fc_replay_state *state; + int ret = JBD2_FC_REPLAY_CONTINUE; + struct ext4_fc_add_range *ext; +- struct ext4_fc_tl *tl; ++ struct ext4_fc_tl tl; + struct ext4_fc_tail tail; +- __u8 *start, *end; ++ __u8 *start, *cur, *end, *val; + struct ext4_fc_head head; + struct ext2fs_extent ext2fs_ex = {0}; + +@@ -313,12 +313,15 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + } + + state->fc_replay_expected_off++; +- fc_for_each_tl(start, end, tl) { ++ for (cur = start; cur < end; cur = cur + le16_to_cpu(tl.fc_len) + sizeof(tl)) { ++ memcpy(&tl, cur, sizeof(tl)); ++ val = cur + sizeof(tl); ++ + jbd_debug(3, "Scan phase, tag:%s, blk %lld\n", +- tag2str(le16_to_cpu(tl->fc_tag)), bh->b_blocknr); +- switch (le16_to_cpu(tl->fc_tag)) { ++ tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr); ++ switch (le16_to_cpu(tl.fc_tag)) { + case EXT4_FC_TAG_ADD_RANGE: +- ext = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); ++ ext = (struct ext4_fc_add_range *)val; + ret = ext2fs_decode_extent(&ext2fs_ex, (void *)&ext->fc_ex, + sizeof(ext->fc_ex)); + if (ret) +@@ -333,14 +336,14 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + case EXT4_FC_TAG_INODE: + case EXT4_FC_TAG_PAD: + state->fc_cur_tag++; +- state->fc_crc = jbd2_chksum(j, state->fc_crc, tl, +- sizeof(*tl) + ext4_fc_tag_len(tl)); ++ state->fc_crc = jbd2_chksum(j, state->fc_crc, cur, ++ sizeof(tl) + ext4_fc_tag_len(&tl)); + break; + case EXT4_FC_TAG_TAIL: + state->fc_cur_tag++; +- memcpy(&tail, ext4_fc_tag_val(tl), sizeof(tail)); +- state->fc_crc = jbd2_chksum(j, state->fc_crc, tl, +- sizeof(*tl) + ++ memcpy(&tail, val, sizeof(tail)); ++ state->fc_crc = jbd2_chksum(j, state->fc_crc, cur, ++ sizeof(tl) + + offsetof(struct ext4_fc_tail, + fc_crc)); + jbd_debug(1, "tail tid %d, expected %d\n", +@@ -355,7 +358,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + state->fc_crc = 0; + break; + case EXT4_FC_TAG_HEAD: +- memcpy(&head, ext4_fc_tag_val(tl), sizeof(head)); ++ memcpy(&head, val, sizeof(head)); + if (le32_to_cpu(head.fc_features) & + ~EXT4_FC_SUPPORTED_FEATURES) { + ret = -EOPNOTSUPP; +@@ -366,8 +369,8 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + break; + } + state->fc_cur_tag++; +- state->fc_crc = jbd2_chksum(j, state->fc_crc, tl, +- sizeof(*tl) + ext4_fc_tag_len(tl)); ++ state->fc_crc = jbd2_chksum(j, state->fc_crc, cur, ++ sizeof(tl) + ext4_fc_tag_len(&tl)); + break; + default: + ret = state->fc_replay_num_tags ? +@@ -612,12 +615,12 @@ struct dentry_info_args { + }; + + static inline int tl_to_darg(struct dentry_info_args *darg, +- struct ext4_fc_tl *tl) ++ struct ext4_fc_tl *tl, __u8 *val) + { + struct ext4_fc_dentry_info fcd; + int tag = le16_to_cpu(tl->fc_tag); + +- memcpy(&fcd, ext4_fc_tag_val(tl), sizeof(fcd)); ++ memcpy(&fcd, val, sizeof(fcd)); + + darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); + darg->ino = le32_to_cpu(fcd.fc_ino); +@@ -627,7 +630,7 @@ static inline int tl_to_darg(struct dentry_info_args *darg, + if (!darg->dname) + return -ENOMEM; + memcpy(darg->dname, +- ext4_fc_tag_val(tl) + sizeof(struct ext4_fc_dentry_info), ++ val + sizeof(struct ext4_fc_dentry_info), + darg->dname_len); + darg->dname[darg->dname_len] = 0; + jbd_debug(1, "%s: %s, ino %d, parent %d\n", +@@ -638,14 +641,14 @@ static inline int tl_to_darg(struct dentry_info_args *darg, + return 0; + } + +-static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl) ++static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl, __u8 *val) + { + struct ext2_inode inode; + struct dentry_info_args darg; + ext2_filsys fs = ctx->fs; + int ret; + +- ret = tl_to_darg(&darg, tl); ++ ret = tl_to_darg(&darg, tl, val); + if (ret) + return ret; + ext4_fc_flush_extents(ctx, darg.ino); +@@ -657,14 +660,14 @@ static int ext4_fc_handle_unlink(e2fsck_t ctx, struct ext4_fc_tl *tl) + return ret; + } + +-static int ext4_fc_handle_link_and_create(e2fsck_t ctx, struct ext4_fc_tl *tl) ++static int ext4_fc_handle_link_and_create(e2fsck_t ctx, struct ext4_fc_tl *tl, __u8 *val) + { + struct dentry_info_args darg; + ext2_filsys fs = ctx->fs; + struct ext2_inode_large inode_large; + int ret, filetype, mode; + +- ret = tl_to_darg(&darg, tl); ++ ret = tl_to_darg(&darg, tl, val); + if (ret) + return ret; + ext4_fc_flush_extents(ctx, 0); +@@ -732,7 +735,7 @@ static void ext4_fc_replay_fixup_iblocks(struct ext2_inode_large *ondisk_inode, + } + } + +-static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) ++static int ext4_fc_handle_inode(e2fsck_t ctx, __u8 *val) + { + struct e2fsck_fc_replay_state *state = &ctx->fc_replay_state; + int ino, inode_len = EXT2_GOOD_OLD_INODE_SIZE; +@@ -742,8 +745,8 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, struct ext4_fc_tl *tl) + errcode_t err; + blk64_t blks; + +- memcpy(&fc_ino, ext4_fc_tag_val(tl), sizeof(fc_ino)); +- fc_raw_inode = ext4_fc_tag_val(tl) + sizeof(fc_ino); ++ memcpy(&fc_ino, val, sizeof(fc_ino)); ++ fc_raw_inode = val + sizeof(fc_ino); + ino = le32_to_cpu(fc_ino); + + if (EXT2_INODE_SIZE(ctx->fs->super) > EXT2_GOOD_OLD_INODE_SIZE) +@@ -797,13 +800,13 @@ out: + /* + * Handle add extent replay tag. + */ +-static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) ++static int ext4_fc_handle_add_extent(e2fsck_t ctx, __u8 *val) + { + struct ext2fs_extent extent; + struct ext4_fc_add_range add_range; + int ret = 0, ino; + +- memcpy(&add_range, ext4_fc_tag_val(tl), sizeof(add_range)); ++ memcpy(&add_range, val, sizeof(add_range)); + ino = le32_to_cpu(add_range.fc_ino); + ext4_fc_flush_extents(ctx, ino); + +@@ -823,13 +826,13 @@ static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) + /* + * Handle delete logical range replay tag. + */ +-static int ext4_fc_handle_del_range(e2fsck_t ctx, struct ext4_fc_tl *tl) ++static int ext4_fc_handle_del_range(e2fsck_t ctx, __u8 *val) + { + struct ext2fs_extent extent; + struct ext4_fc_del_range del_range; + int ret, ino; + +- memcpy(&del_range, ext4_fc_tag_val(tl), sizeof(del_range)); ++ memcpy(&del_range, val, sizeof(del_range)); + ino = le32_to_cpu(del_range.fc_ino); + ext4_fc_flush_extents(ctx, ino); + +@@ -854,8 +857,8 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, + e2fsck_t ctx = journal->j_fs_dev->k_ctx; + struct e2fsck_fc_replay_state *state = &ctx->fc_replay_state; + int ret = JBD2_FC_REPLAY_CONTINUE; +- struct ext4_fc_tl *tl; +- __u8 *start, *end; ++ struct ext4_fc_tl tl; ++ __u8 *start, *end, *cur, *val; + + if (pass == PASS_SCAN) { + state->fc_current_pass = PASS_SCAN; +@@ -891,28 +894,31 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, + start = (__u8 *)bh->b_data; + end = (__u8 *)bh->b_data + journal->j_blocksize - 1; + +- fc_for_each_tl(start, end, tl) { ++ for (cur = start; cur < end; cur = cur + le16_to_cpu(tl.fc_len) + sizeof(tl)) { ++ memcpy(&tl, cur, sizeof(tl)); ++ val = cur + sizeof(tl); ++ + if (state->fc_replay_num_tags == 0) + goto replay_done; + jbd_debug(3, "Replay phase processing %s tag\n", +- tag2str(le16_to_cpu(tl->fc_tag))); ++ tag2str(le16_to_cpu(tl.fc_tag))); + state->fc_replay_num_tags--; +- switch (le16_to_cpu(tl->fc_tag)) { ++ switch (le16_to_cpu(tl.fc_tag)) { + case EXT4_FC_TAG_CREAT: + case EXT4_FC_TAG_LINK: +- ret = ext4_fc_handle_link_and_create(ctx, tl); ++ ret = ext4_fc_handle_link_and_create(ctx, &tl, val); + break; + case EXT4_FC_TAG_UNLINK: +- ret = ext4_fc_handle_unlink(ctx, tl); ++ ret = ext4_fc_handle_unlink(ctx, &tl, val); + break; + case EXT4_FC_TAG_ADD_RANGE: +- ret = ext4_fc_handle_add_extent(ctx, tl); ++ ret = ext4_fc_handle_add_extent(ctx, val); + break; + case EXT4_FC_TAG_DEL_RANGE: +- ret = ext4_fc_handle_del_range(ctx, tl); ++ ret = ext4_fc_handle_del_range(ctx, val); + break; + case EXT4_FC_TAG_INODE: +- ret = ext4_fc_handle_inode(ctx, tl); ++ ret = ext4_fc_handle_inode(ctx, val); + break; + case EXT4_FC_TAG_TAIL: + ext4_fc_flush_extents(ctx, 0); +diff --git a/lib/ext2fs/fast_commit.h b/lib/ext2fs/fast_commit.h +index b83e1810..4ad38f12 100644 +--- a/lib/ext2fs/fast_commit.h ++++ b/lib/ext2fs/fast_commit.h +@@ -155,13 +155,6 @@ struct ext4_fc_replay_state { + #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1) + #endif + +-#define fc_for_each_tl(__start, __end, __tl) \ +- for (tl = (struct ext4_fc_tl *)(__start); \ +- (__u8 *)tl < (__u8 *)(__end); \ +- tl = (struct ext4_fc_tl *)((__u8 *)tl + \ +- sizeof(struct ext4_fc_tl) + \ +- + le16_to_cpu(tl->fc_len))) +- + static inline const char *tag2str(__u16 tag) + { + switch (tag) { +@@ -194,10 +187,4 @@ static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl) + return le16_to_cpu(tl->fc_len); + } + +-/* Get a pointer to "value" of a tlv */ +-static inline __u8 *ext4_fc_tag_val(struct ext4_fc_tl *tl) +-{ +- return (__u8 *)tl + sizeof(*tl); +-} +- + #endif /* __FAST_COMMIT_H__ */ +-- +2.24.4 + diff --git a/1007-e2fsck-fix-unaligned-accesses-to-ext4_fc_add_range-a.patch b/1007-e2fsck-fix-unaligned-accesses-to-ext4_fc_add_range-a.patch new file mode 100644 index 0000000000000000000000000000000000000000..80f7422ac765e11803cda356d6c32d09a3834834 --- /dev/null +++ b/1007-e2fsck-fix-unaligned-accesses-to-ext4_fc_add_range-a.patch @@ -0,0 +1,64 @@ +From 9269fda7aa0af5aef422f652f3d3b9f112c8239a Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 6 May 2021 22:40:57 -0400 +Subject: [PATCH 7/9] e2fsck: fix unaligned accesses to ext4_fc_add_range and + fc_raw_inode + +These fast commit related structures can be unaligned on disk. So we +need to avoid accessing these structures directly, and first copy +them to memory which we know is appropriately aligned. + +This fixes an e2fsck crash while running the j_recovery_fast_commit +regression test on a sparc64 system. + +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/journal.c | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +diff --git a/e2fsck/journal.c b/e2fsck/journal.c +index ae3df800..0128fbd3 100644 +--- a/e2fsck/journal.c ++++ b/e2fsck/journal.c +@@ -284,7 +284,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + e2fsck_t ctx = j->j_fs_dev->k_ctx; + struct e2fsck_fc_replay_state *state; + int ret = JBD2_FC_REPLAY_CONTINUE; +- struct ext4_fc_add_range *ext; ++ struct ext4_fc_add_range ext; + struct ext4_fc_tl tl; + struct ext4_fc_tail tail; + __u8 *start, *cur, *end, *val; +@@ -321,9 +321,10 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh, + tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr); + switch (le16_to_cpu(tl.fc_tag)) { + case EXT4_FC_TAG_ADD_RANGE: +- ext = (struct ext4_fc_add_range *)val; +- ret = ext2fs_decode_extent(&ext2fs_ex, (void *)&ext->fc_ex, +- sizeof(ext->fc_ex)); ++ memcpy(&ext, val, sizeof(ext)); ++ ret = ext2fs_decode_extent(&ext2fs_ex, ++ (void *)&ext.fc_ex, ++ sizeof(ext.fc_ex)); + if (ret) + ret = JBD2_FC_REPLAY_STOP; + else +@@ -764,12 +765,9 @@ static int ext4_fc_handle_inode(e2fsck_t ctx, __u8 *val) + inode_len); + if (err) + goto out; +-#ifdef WORDS_BIGENDIAN +- ext2fs_swap_inode_full(ctx->fs, fc_inode, +- (struct ext2_inode_large *)fc_raw_inode, +- 0, sizeof(*inode)); +-#else + memcpy(fc_inode, fc_raw_inode, inode_len); ++#ifdef WORDS_BIGENDIAN ++ ext2fs_swap_inode_full(ctx->fs, fc_inode, fc_inode, 0, inode_len); + #endif + memcpy(inode, fc_inode, offsetof(struct ext2_inode_large, i_block)); + memcpy(&inode->i_generation, &fc_inode->i_generation, +-- +2.24.4 + diff --git a/1008-e2fsck-sync-fc_do_one_pass-changes-from-kernel.patch b/1008-e2fsck-sync-fc_do_one_pass-changes-from-kernel.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9bf18cadfe2969365de32aed1ff95d86bd0c769 --- /dev/null +++ b/1008-e2fsck-sync-fc_do_one_pass-changes-from-kernel.patch @@ -0,0 +1,40 @@ +From 58ed5445c5b44c2e629c65ffbadc948f9bfc01d8 Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Tue, 15 Jun 2021 21:53:30 -0700 +Subject: [PATCH 8/9] e2fsck: sync fc_do_one_pass() changes from kernel + +Sync the changes to fc_do_one_pass() from the kernel's recovery.c so +that e2fsck picks up the fixes to the jbd_debug() statements. + +Signed-off-by: Eric Biggers +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + e2fsck/recovery.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c +index 02694d2c..25744f08 100644 +--- a/e2fsck/recovery.c ++++ b/e2fsck/recovery.c +@@ -245,15 +245,14 @@ static int fc_do_one_pass(journal_t *journal, + return 0; + + while (next_fc_block <= journal->j_fc_last) { +- jbd_debug(3, "Fast commit replay: next block %ld", ++ jbd_debug(3, "Fast commit replay: next block %ld\n", + next_fc_block); + err = jread(&bh, journal, next_fc_block); + if (err) { +- jbd_debug(3, "Fast commit replay: read error"); ++ jbd_debug(3, "Fast commit replay: read error\n"); + break; + } + +- jbd_debug(3, "Processing fast commit blk with seq %d"); + err = journal->j_fc_replay_callback(journal, bh, pass, + next_fc_block - journal->j_fc_first, + expected_commit_id); +-- +2.24.4 + diff --git a/1009-tests-add-description-for-j_recover_fast_commit.patch b/1009-tests-add-description-for-j_recover_fast_commit.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf52d637ffca057b8389c1750a0aef4463b67278 --- /dev/null +++ b/1009-tests-add-description-for-j_recover_fast_commit.patch @@ -0,0 +1,26 @@ +From f9ce3c65b5eeaa89f190e8d02cb65b2eb28a2e41 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 29 Jul 2021 17:42:23 -0400 +Subject: [PATCH 9/9] tests: add description for j_recover_fast_commit + +Signed-off-by: Theodore Ts'o +Signed-off-by: Joseph Qi +--- + tests/j_recover_fast_commit/script | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/j_recover_fast_commit/script b/tests/j_recover_fast_commit/script +index 05c40cc5..14cbb60f 100755 +--- a/tests/j_recover_fast_commit/script ++++ b/tests/j_recover_fast_commit/script +@@ -3,6 +3,7 @@ + FSCK_OPT=-fy + IMAGE=$test_dir/image.gz + CMDS=$test_dir/commands ++test_description="replay fast commit journal" + + gunzip < $IMAGE > $TMPFILE + +-- +2.24.4 + diff --git a/download b/download index 4a43047bd8812af0f2a3fe52406ef658db0285fa..6b29d7ae294f9b49724daeae206d9381aad31406 100644 --- a/download +++ b/download @@ -1 +1 @@ -b3ff2a22462ecd545613923ab2c31da8 e2fsprogs-1.45.6.tar.xz +aaea2fcdaef6ece1dbd9dbc9429fe24c e2fsprogs-1.46.0.tar.xz diff --git a/e2fsprogs-1.45.6-mke2fs-Escape-double-quotes-when-parsing-mke2fs.conf.patch b/e2fsprogs-1.45.6-mke2fs-Escape-double-quotes-when-parsing-mke2fs.conf.patch deleted file mode 100644 index 471b4d5e919d38c780d69d7996bd712524c9e6ec..0000000000000000000000000000000000000000 --- a/e2fsprogs-1.45.6-mke2fs-Escape-double-quotes-when-parsing-mke2fs.conf.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 6fa8edd0fde7a540b41d78e45743208c8edab0b1 Mon Sep 17 00:00:00 2001 -From: Lukas Czerner -Date: Mon, 2 Nov 2020 15:26:31 +0100 -Subject: [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf - -Currently, when constructing the configuration pseudo-file using -the profile-to-c.awk script we will just pass the double quotes as they -appear in the mke2fs.conf. - -This is problematic, because the resulting default_profile.c will either -fail to compile because of syntax error, or leave the resulting -configuration invalid. - -It can be reproduced by adding the following line somewhere into -mke2fs.conf configuration and forcing mke2fs to use the -configuration by specifying nonexistent mke2fs.conf - -MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device - -default_mntopts = "acl,user_xattr" -^ this will fail to compile - -default_mntopts = "" -^ this will result in invalid config file - -Syntax error in mke2fs config file (, line #4) - Unknown code prof 17 - -Fix it by escaping the double quotes with a backslash in -profile-to-c.awk script. - -Signed-off-by: Lukas Czerner -Signed-off-by: Theodore Ts'o ---- - misc/profile-to-c.awk | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk -index f964efd6..814f7236 100644 ---- a/misc/profile-to-c.awk -+++ b/misc/profile-to-c.awk -@@ -4,6 +4,7 @@ BEGIN { - } - - { -+ gsub("\"","\\\"",$0); - printf(" \"%s\\n\"\n", $0); - } - --- -2.26.3 - diff --git a/e2fsprogs.spec b/e2fsprogs.spec index a5058635da6e365beaa95350798cf2039b11867b..912b2896849cdce8bf5e6e686173334b4d445d0d 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,8 +1,8 @@ %define anolis_release .0.1 Summary: Utilities for managing ext2, ext3, and ext4 file systems Name: e2fsprogs -Version: 1.45.6 -Release: 4%{anolis_release}%{?dist} +Version: 1.46.0 +Release: 1%{anolis_release}%{?dist} # License tags based on COPYING file distinctions for various components License: GPLv2 @@ -28,20 +28,27 @@ BuildRequires: libuuid-devel BuildRequires: gettext BuildRequires: multilib-rpm-config -Patch0: e2fsprogs-1.45.6-Makefile.in-Disable-e2scrub.patch -Patch1: e2fsprogs-1.45.6-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch -Patch2: e2fsprogs-1.45.6-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch -Patch3: e2fsprogs-1.45.6-man-Add-note-about-RHEL8-supported-features-and-moun.patch -Patch4: e2fsprogs-1.45.6-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch -Patch5: e2fsprogs-1.45.6-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch -Patch6: e2fsprogs-1.45.6-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch -Patch7: e2fsprogs-1.45.6-mke2fs-Escape-double-quotes-when-parsing-mke2fs.conf.patch -Patch8: 0001-reisze2fs-sanity-check-free-block-group-counts-when-.patch -Patch9: 0001-tests-support-older-versions-of-timeout-in-r_corrupt.patch -Patch10: 0001-tests-specify-inode-size-in-r_corrupt_fs.patch +Patch0: 0001-Makefile.in-Disable-e2scrub.patch +Patch1: 0002-Revert-fuse2fs-install-fuse2fs-in-usr-bin-instead-of.patch +Patch2: 0003-mke2fs.conf-Introduce-rhel6-and-rhel7-fs_type.patch +Patch3: 0004-man-Add-note-about-RHEL8-supported-features-and-moun.patch +Patch4: 0005-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch +Patch5: 0006-Revert-libext2fs-hide-struct-ext2fs_hashmap-as-an-in.patch +Patch6: 0007-ext2fs-fix-ABI-change-in-the-struct_ext2_filsys-stru.patch +Patch7: 0008-reisze2fs-sanity-check-free-block-group-counts-when-.patch +Patch8: 0009-tests-support-older-versions-of-timeout-in-r_corrupt.patch +Patch9: 0010-tests-specify-inode-size-in-r_corrupt_fs.patch # Begin: Anolis customized patches -Patch1001: 1001-e2fsprogs-1.44.6-disable-metadata_csum-by-default.patch +Patch1001: 1001-Disable-metadata_csum-for-ext4-by-default-until-upst.patch +Patch1002: 1002-e2fsck-endianness-fixes-for-fast-commit-replay.patch +Patch1003: 1003-e2fsck-add-fallthrough-comment-in-fc-replay-switch-c.patch +Patch1004: 1004-e2fsck-initialize-variable-before-first-use-in-fast-.patch +Patch1005: 1005-e2fsck-fix-portability-problems-caused-by-unaligned-.patch +Patch1006: 1006-e2fsck-fix-unaligned-accesses-to-ext4_fc_tl-struct.patch +Patch1007: 1007-e2fsck-fix-unaligned-accesses-to-ext4_fc_add_range-a.patch +Patch1008: 1008-e2fsck-sync-fc_do_one_pass-changes-from-kernel.patch +Patch1009: 1009-tests-add-description-for-j_recover_fast_commit.patch # End: Anolis customized patches %description @@ -171,8 +178,16 @@ It was originally inspired by the Multics SubSystem library. %patch7 -p1 %patch8 -p1 %patch9 -p1 -%patch10 -p1 + %patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch1005 -p1 +%patch1006 -p1 +%patch1007 -p1 +%patch1008 -p1 +%patch1009 -p1 %build %configure CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" \ @@ -335,6 +350,9 @@ exit 0 %{_libdir}/pkgconfig/ss.pc %changelog +* Mon Aug 15 2022 Joseph Qi 1.46.0-1.0.1 +- Rebase to upstream release 1.46.0, to support ext4 fast commit + * Tue May 17 2022 Weitao Zhou 1.45.6-4.0.1 - Disable metadata_csum for ext4 by default