aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2005-11-12 23:30:39 -0500
committerTheodore Ts'o <tytso@mit.edu>2005-11-12 23:30:39 -0500
commit0d961040fe9ad927254b5a0e1a4de7bedadd8579 (patch)
tree4fc2bc854b23cdeee774f3b4d93e23d0e95677f0
parentdd947da232d2442f86c2f4d595cf7d3b76604e49 (diff)
downloade2fsprogs-0d961040fe9ad927254b5a0e1a4de7bedadd8579.tar.gz
e2fsprogs-0d961040fe9ad927254b5a0e1a4de7bedadd8579.tar.xz
e2fsprogs-0d961040fe9ad927254b5a0e1a4de7bedadd8579.zip
Fix writing external journals on big-endian machines
Fix a bug when writing an external journal device on an big endian machine (such as a S/390), where when the number of block groups is zero, we never end up writing out the primary superblock at all. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--lib/ext2fs/ChangeLog7
-rw-r--r--lib/ext2fs/closefs.c34
2 files changed, 25 insertions, 16 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 5e2530ea..93eccb39 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,10 @@
+2005-11-09 Theodore Ts'o <tytso@mit.edu>
+
+ * Fix a bug when writing an external journal device on an big
+ endian machine (such as a S/390), where when the number of
+ block groups is zero, we never end up writing out the
+ primary superblock at all.
+
2005-09-24 Theodore Ts'o <tytso@mit.edu>
* ext2fs.h, bb_inode.c, closefs.c, initialize.c, mkdir.c,
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 6a151937..58f1a8b1 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -251,14 +251,6 @@ errcode_t ext2fs_flush(ext2_filsys fs)
#endif
/*
- * If this is an external journal device, don't write out the
- * block group descriptors or any of the backup superblocks
- */
- if (fs->super->s_feature_incompat &
- EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
- goto write_primary_superblock_only;
-
- /*
* Set the state of the FS to be non-valid. (The state has
* already been backed up earlier, and will be restored after
* we write out the backup superblocks.)
@@ -272,6 +264,14 @@ errcode_t ext2fs_flush(ext2_filsys fs)
#endif
/*
+ * If this is an external journal device, don't write out the
+ * block group descriptors or any of the backup superblocks
+ */
+ if (fs->super->s_feature_incompat &
+ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
+ goto write_primary_superblock_only;
+
+ /*
* Write out the master group descriptors, and the backup
* superblocks and group descriptors.
*/
@@ -311,14 +311,6 @@ errcode_t ext2fs_flush(ext2_filsys fs)
goto errout;
}
}
- fs->super->s_block_group_nr = 0;
- fs->super->s_state = fs_state;
-#ifdef EXT2FS_ENABLE_SWAPFS
- if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
- *super_shadow = *fs->super;
- ext2fs_swap_super(super_shadow);
- }
-#endif
/*
* If the write_bitmaps() function is present, call it to
@@ -340,6 +332,16 @@ write_primary_superblock_only:
* out to disk first, just to avoid a race condition with an
* insy-tinsy window....
*/
+
+ fs->super->s_block_group_nr = 0;
+ fs->super->s_state = fs_state;
+#ifdef EXT2FS_ENABLE_SWAPFS
+ if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
+ *super_shadow = *fs->super;
+ ext2fs_swap_super(super_shadow);
+ }
+#endif
+
retval = io_channel_flush(fs->io);
retval = write_primary_superblock(fs, super_shadow);
if (retval)