Blame SOURCES/e2fsprogs-1.45.6-libext2fs-don-t-needlessly-byte-swap-the-group-descr.patch

a77133
From 1aecdcc5c805e5e2114dd14877e9e1771fb519bf Mon Sep 17 00:00:00 2001
a77133
From: Theodore Ts'o <tytso@mit.edu>
a77133
Date: Thu, 16 Jan 2020 19:17:26 -0500
a77133
Subject: [PATCH 04/46] libext2fs: don't needlessly byte swap the group
a77133
 descriptors in ext2fs_flush
a77133
Content-Type: text/plain
a77133
a77133
If the EXT2_FLAG_SUPER_ONLY is set, there's no reason to allocate the
a77133
shadow block group descriptors and byte swap the group descriptors.
a77133
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 lib/ext2fs/closefs.c | 24 ++++++++++++++----------
a77133
 1 file changed, 14 insertions(+), 10 deletions(-)
a77133
a77133
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
a77133
index 6814cdc3..69cbdd8c 100644
a77133
--- a/lib/ext2fs/closefs.c
a77133
+++ b/lib/ext2fs/closefs.c
a77133
@@ -331,20 +331,24 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
a77133
 #ifdef WORDS_BIGENDIAN
a77133
 	retval = EXT2_ET_NO_MEMORY;
a77133
 	retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow);
a77133
-	if (retval)
a77133
-		goto errout;
a77133
-	retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
a77133
-				  &group_shadow);
a77133
 	if (retval)
a77133
 		goto errout;
a77133
 	memcpy(super_shadow, fs->super, sizeof(struct ext2_super_block));
a77133
-	memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize *
a77133
-	       fs->desc_blocks);
a77133
-
a77133
 	ext2fs_swap_super(super_shadow);
a77133
-	for (j = 0; j < fs->group_desc_count; j++) {
a77133
-		gdp = ext2fs_group_desc(fs, group_shadow, j);
a77133
-		ext2fs_swap_group_desc2(fs, gdp);
a77133
+
a77133
+	if (((fs->flags & EXT2_FLAG_SUPER_ONLY) == 0) &&
a77133
+	    !ext2fs_has_feature_journal_dev(fs->super)) {
a77133
+		retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
a77133
+					  &group_shadow);
a77133
+		if (retval)
a77133
+			goto errout;
a77133
+		memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize *
a77133
+		       fs->desc_blocks);
a77133
+
a77133
+		for (j = 0; j < fs->group_desc_count; j++) {
a77133
+			gdp = ext2fs_group_desc(fs, group_shadow, j);
a77133
+			ext2fs_swap_group_desc2(fs, gdp);
a77133
+		}
a77133
 	}
a77133
 #else
a77133
 	super_shadow = fs->super;
a77133
-- 
a77133
2.35.1
a77133