diff options
author | Theodore Ts'o <tytso@mit.edu> | 2020-01-16 19:17:26 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-01-16 19:49:06 -0500 |
commit | df659444466bae4ea78807da2cf021c135103268 (patch) | |
tree | c8d6dd2a7a3043b504bbc8d51dc049283606b4c3 | |
parent | c8651b4bf6b31c975d92c4c056b8a1bc25a41f9e (diff) | |
download | e2fsprogs-df659444466bae4ea78807da2cf021c135103268.tar.gz |
libext2fs: don't needlessly byte swap the group descriptors in ext2fs_flush
If the EXT2_FLAG_SUPER_ONLY is set, there's no reason to allocate the
shadow block group descriptors and byte swap the group descriptors.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | lib/ext2fs/closefs.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 6814cdc32..69cbdd8c1 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -333,18 +333,22 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags) retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow); if (retval) goto errout; - retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, - &group_shadow); - if (retval) - goto errout; memcpy(super_shadow, fs->super, sizeof(struct ext2_super_block)); - memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize * - fs->desc_blocks); - ext2fs_swap_super(super_shadow); - for (j = 0; j < fs->group_desc_count; j++) { - gdp = ext2fs_group_desc(fs, group_shadow, j); - ext2fs_swap_group_desc2(fs, gdp); + + if (((fs->flags & EXT2_FLAG_SUPER_ONLY) == 0) && + !ext2fs_has_feature_journal_dev(fs->super)) { + retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, + &group_shadow); + if (retval) + goto errout; + memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize * + fs->desc_blocks); + + for (j = 0; j < fs->group_desc_count; j++) { + gdp = ext2fs_group_desc(fs, group_shadow, j); + ext2fs_swap_group_desc2(fs, gdp); + } } #else super_shadow = fs->super; |